In [ ]:
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
Data = pd.read_csv (r'C:\Users\erdil/Desktop/all_ticks_wide.csv')
Data.head()
Out[ ]:
timestamp AEFES AKBNK AKSA AKSEN ALARK ALBRK ANACM ARCLK ASELS ... TTKOM TUKAS TUPRS USAK VAKBN VESTL YATAS YKBNK YUNSA ZOREN
0 2012-09-17T06:45:00Z 22.3978 5.2084 1.7102 3.87 1.4683 1.1356 1.0634 6.9909 2.9948 ... 4.2639 0.96 29.8072 1.0382 3.8620 1.90 0.4172 2.5438 2.2619 0.7789
1 2012-09-17T07:00:00Z 22.3978 5.1938 1.7066 3.86 1.4574 1.1275 1.0634 6.9259 2.9948 ... 4.2521 0.96 29.7393 1.0382 3.8529 1.90 0.4229 2.5266 2.2462 0.7789
2 2012-09-17T07:15:00Z 22.3978 5.2084 1.7102 NaN 1.4610 1.1356 1.0679 6.9909 2.9855 ... 4.2521 0.97 29.6716 1.0463 3.8436 1.91 0.4229 2.5266 2.2566 0.7789
3 2012-09-17T07:30:00Z 22.3978 5.1938 1.7102 3.86 1.4537 1.1275 1.0679 6.9584 2.9855 ... 4.2521 0.97 29.7393 1.0382 3.8529 1.91 0.4286 2.5324 2.2619 0.7860
4 2012-09-17T07:45:00Z 22.5649 5.2084 1.7102 3.87 1.4574 1.1356 1.0725 6.9909 2.9760 ... 4.2521 0.97 29.8072 1.0382 3.8620 1.90 0.4286 2.5324 2.2619 0.7789

5 rows × 61 columns

In [ ]:
Data.describe()
Out[ ]:
AEFES AKBNK AKSA AKSEN ALARK ALBRK ANACM ARCLK ASELS ASUZU ... TTKOM TUKAS TUPRS USAK VAKBN VESTL YATAS YKBNK YUNSA ZOREN
count 48131.000000 49209.000000 48594.000000 48171.000000 48335.000000 46862.000000 48165.000000 49045.000000 48803.000000 48433.000000 ... 49077.000000 45929.000000 49143.000000 47659.000000 49212.000000 48781.000000 46055.000000 49225.000000 45528.000000 48807.000000
mean 20.982235 6.473105 7.127504 3.183542 2.060859 1.365549 1.672102 15.388088 13.432535 6.467033 ... 5.660680 1.737529 62.994535 1.220452 4.735438 5.942711 2.434249 2.566327 4.079695 1.248124
std 2.494002 0.944955 2.710033 0.724332 0.575943 0.167824 0.788365 4.531459 9.624246 2.201036 ... 0.818598 0.867095 32.398117 0.459532 0.977889 2.830465 2.552377 0.422774 1.347020 0.311330
min 0.000100 0.000100 0.000100 0.000000 0.000100 1.025500 0.000100 0.000100 0.000100 0.000100 ... 0.000100 0.650000 0.000100 0.000100 0.000100 0.000000 0.000100 0.000100 0.000100 0.000100
25% 19.160500 5.850000 5.208800 2.670000 1.568900 1.225100 1.047000 11.711100 4.940300 5.074800 ... 5.267300 1.060000 34.549100 0.957100 4.032200 4.020000 0.388600 2.268200 3.006700 1.033800
50% 20.646500 6.305700 6.985300 2.930000 1.937600 1.360200 1.259700 15.010000 9.275700 5.949600 ... 5.746400 1.530000 49.554200 1.050000 4.474200 6.320000 0.965800 2.609300 4.107800 1.250000
75% 22.732000 6.932500 8.720000 3.750000 2.421400 1.500000 2.402100 19.087700 22.756700 7.120000 ... 6.260000 2.130000 93.428700 1.370800 5.246000 7.450000 4.230000 2.874000 4.720600 1.426500
max 28.509000 9.212400 15.118900 5.190000 3.514300 2.190000 3.502100 26.427800 46.761600 15.280000 ... 7.350000 5.920000 139.293700 2.757800 7.581400 14.540000 10.674800 3.958100 9.527500 2.443000

8 rows × 60 columns

In [ ]:
Data.tail(20)
Out[ ]:
timestamp AEFES AKBNK AKSA AKSEN ALARK ALBRK ANACM ARCLK ASELS ... TTKOM TUKAS TUPRS USAK VAKBN VESTL YATAS YKBNK YUNSA ZOREN
49992 2019-07-23T09:45:00Z 20.50 7.75 9.19 2.47 3.25 1.22 2.89 20.32 NaN ... 5.65 4.28 130.4 1.05 4.86 9.98 5.31 2.77 4.26 NaN
49993 2019-07-23T10:00:00Z NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN 130.4 NaN NaN NaN NaN NaN NaN NaN
49994 2019-07-23T10:45:00Z 20.46 7.76 9.18 2.47 3.25 1.21 2.89 20.30 NaN ... 5.65 4.28 130.4 1.05 4.86 9.98 5.31 2.77 4.26 NaN
49995 2019-07-23T11:00:00Z 20.40 7.76 9.17 2.46 3.25 1.21 2.88 20.34 NaN ... 5.66 4.28 130.6 1.05 4.87 9.96 5.34 2.76 4.27 NaN
49996 2019-07-23T11:15:00Z 20.40 7.74 9.17 2.46 3.24 1.21 2.87 20.36 NaN ... 5.65 4.41 130.8 1.05 4.86 9.99 5.32 2.76 4.27 NaN
49997 2019-07-23T11:30:00Z 20.40 7.72 9.16 2.47 3.24 1.21 2.86 20.32 NaN ... 5.62 4.39 130.0 1.04 4.85 9.98 5.33 2.76 4.25 NaN
49998 2019-07-23T11:45:00Z 20.38 7.70 9.14 2.46 3.23 1.21 2.86 20.28 NaN ... 5.60 4.37 130.4 1.05 4.85 9.97 5.33 2.76 4.24 NaN
49999 2019-07-23T12:00:00Z 20.46 7.71 9.15 2.46 3.24 1.21 2.87 20.28 NaN ... 5.60 4.39 130.2 1.05 4.86 9.97 5.32 2.75 4.24 NaN
50000 2019-07-23T12:15:00Z 20.42 7.71 9.18 2.45 3.23 1.20 2.86 20.28 NaN ... 5.58 4.34 130.5 1.04 4.85 9.98 5.32 2.75 4.24 NaN
50001 2019-07-23T12:30:00Z 20.48 7.73 9.16 2.45 3.24 1.21 2.85 20.34 NaN ... 5.60 4.34 131.0 1.04 4.88 9.98 5.33 2.76 4.26 NaN
50002 2019-07-23T12:45:00Z 20.50 7.72 9.18 2.45 3.23 1.21 2.86 20.34 NaN ... 5.58 4.34 130.7 1.04 4.88 9.98 5.33 2.75 4.26 NaN
50003 2019-07-23T13:00:00Z 20.44 7.73 9.15 2.45 3.24 1.21 2.86 20.24 NaN ... 5.60 4.33 131.5 1.04 4.87 9.97 5.32 2.75 4.24 NaN
50004 2019-07-23T13:15:00Z 20.42 7.72 9.15 2.45 3.24 1.21 2.84 20.24 NaN ... 5.59 4.32 131.0 1.04 4.88 9.97 5.34 2.75 4.25 NaN
50005 2019-07-23T13:30:00Z 20.46 7.73 9.14 2.47 3.24 1.21 2.84 20.18 NaN ... 5.59 4.34 131.5 1.05 4.90 9.97 5.34 2.74 4.25 NaN
50006 2019-07-23T13:45:00Z 20.50 7.73 9.14 2.46 3.23 1.21 2.84 20.22 NaN ... 5.57 4.34 131.5 1.05 4.89 9.97 5.33 2.74 4.24 NaN
50007 2019-07-23T14:00:00Z 20.48 7.73 9.14 2.47 3.23 1.21 2.84 20.30 NaN ... 5.60 4.34 131.6 1.05 4.86 9.98 5.35 2.75 4.25 NaN
50008 2019-07-23T14:15:00Z 20.50 7.72 9.14 2.47 3.22 1.21 2.84 20.32 NaN ... 5.57 4.35 131.5 1.05 4.86 9.98 5.34 2.75 4.24 NaN
50009 2019-07-23T14:30:00Z 20.50 7.74 9.13 2.46 3.23 1.21 2.83 20.34 NaN ... 5.57 4.36 131.5 1.05 4.86 9.96 5.34 2.76 4.24 NaN
50010 2019-07-23T14:45:00Z 20.40 7.70 9.14 2.47 3.24 1.21 2.82 20.38 NaN ... 5.57 4.35 131.3 1.04 4.86 9.94 5.34 2.77 4.24 NaN
50011 2019-07-23T15:00:00Z 20.46 7.70 9.14 2.47 3.23 1.20 2.83 20.32 NaN ... 5.56 4.34 131.8 1.05 4.85 9.93 5.33 2.77 4.24 NaN

20 rows × 61 columns

In [ ]:
print(Data.head(20))
               timestamp    AEFES   AKBNK    AKSA  AKSEN   ALARK   ALBRK  \
0   2012-09-17T06:45:00Z  22.3978  5.2084  1.7102   3.87  1.4683  1.1356   
1   2012-09-17T07:00:00Z  22.3978  5.1938  1.7066   3.86  1.4574  1.1275   
2   2012-09-17T07:15:00Z  22.3978  5.2084  1.7102    NaN  1.4610  1.1356   
3   2012-09-17T07:30:00Z  22.3978  5.1938  1.7102   3.86  1.4537  1.1275   
4   2012-09-17T07:45:00Z  22.5649  5.2084  1.7102   3.87  1.4574  1.1356   
5   2012-09-17T08:00:00Z  22.5649  5.2229  1.7102   3.86  1.4610  1.1275   
6   2012-09-17T08:15:00Z  22.5649  5.2229  1.7066    NaN  1.4610  1.1275   
7   2012-09-17T08:30:00Z  22.5649  5.2084  1.7066   3.86  1.4610     NaN   
8   2012-09-17T08:45:00Z  22.5649  5.2372  1.6995    NaN  1.4610  1.1275   
9   2012-09-17T09:00:00Z  22.5649  5.2372  1.6995   3.86  1.4610  1.1356   
10  2012-09-17T09:15:00Z  22.5649  5.2372  1.6995    NaN  1.4574  1.1435   
11  2012-09-17T11:00:00Z  22.4815  5.2372  1.6956    NaN  1.4574  1.1435   
12  2012-09-17T11:15:00Z  22.4815  5.2084  1.6956    NaN  1.4610  1.1435   
13  2012-09-17T11:30:00Z  22.6485  5.2084  1.6920   3.86  1.4574  1.1356   
14  2012-09-17T11:45:00Z  22.6485  5.1938  1.6956   3.86  1.4574  1.1435   
15  2012-09-17T12:00:00Z  22.4815  5.1793  1.6883   3.86  1.4574  1.1356   
16  2012-09-17T12:15:00Z  22.5649  5.1793  1.6956   3.87  1.4574  1.1196   
17  2012-09-17T12:30:00Z  22.3141  5.1505  1.6920   3.87  1.4574  1.1275   
18  2012-09-17T12:45:00Z  22.3978  5.1793  1.6920   3.87  1.4610  1.1196   
19  2012-09-17T13:00:00Z  22.3978  5.1793  1.6956   3.88  1.4537  1.1196   

     ANACM   ARCLK   ASELS  ...   TTKOM  TUKAS    TUPRS    USAK   VAKBN  \
0   1.0634  6.9909  2.9948  ...  4.2639   0.96  29.8072  1.0382  3.8620   
1   1.0634  6.9259  2.9948  ...  4.2521   0.96  29.7393  1.0382  3.8529   
2   1.0679  6.9909  2.9855  ...  4.2521   0.97  29.6716  1.0463  3.8436   
3   1.0679  6.9584  2.9855  ...  4.2521   0.97  29.7393  1.0382  3.8529   
4   1.0725  6.9909  2.9760  ...  4.2521   0.97  29.8072  1.0382  3.8620   
5   1.0725  6.9584  2.9760  ...  4.2402    NaN  29.8072  1.0382  3.8620   
6   1.0679  6.9584  2.9760  ...  4.2402   0.97  29.6716  1.0382  3.8529   
7   1.0725  6.9909  2.9855  ...  4.2168   0.97  29.7393  1.0463  3.8529   
8   1.0725  6.9909  2.9855  ...  4.2285   0.96  29.7393  1.0382  3.8620   
9   1.0725  6.9909  2.9855  ...  4.2285   0.97  29.7393  1.0382  3.8620   
10  1.0725  6.9909  2.9760  ...  4.2402   0.98  29.8072  1.0382  3.8529   
11  1.0725  6.9259  2.9855  ...  4.2285    NaN  29.8072  1.0463  3.8529   
12     NaN  6.8933  2.9760  ...  4.2285   0.97  29.8072  1.0382  3.8529   
13  1.0679  6.8933  2.9855  ...  4.2285   0.97  29.7393  1.0382  3.8529   
14     NaN  6.8933  2.9760  ...  4.2285   0.97  29.8748  1.0382  3.8529   
15  1.0679  6.8283  2.9855  ...  4.2285    NaN  29.8748  1.0301  3.8529   
16  1.0679  6.7958  2.9855  ...  4.2168   0.97  29.8748  1.0382  3.8529   
17  1.0679  6.7634  2.9855  ...  4.2168   0.96  29.8072  1.0382  3.8345   
18  1.0679  6.8283  2.9760  ...  4.2168    NaN  29.8748  1.0301  3.8436   
19  1.0725  6.8283  2.9948  ...  4.2049   0.97  30.0103  1.0382  3.8529   

    VESTL   YATAS   YKBNK   YUNSA   ZOREN  
0    1.90  0.4172  2.5438  2.2619  0.7789  
1    1.90  0.4229  2.5266  2.2462  0.7789  
2    1.91  0.4229  2.5266  2.2566  0.7789  
3    1.91  0.4286  2.5324  2.2619  0.7860  
4    1.90  0.4286  2.5324  2.2619  0.7789  
5    1.91  0.4314  2.5381  2.2566  0.7860  
6    1.91  0.4286  2.5324  2.2566  0.7789  
7    1.91  0.4286  2.5266  2.2566  0.7860  
8    1.90  0.4314  2.5381  2.2514  0.7789  
9    1.91  0.4314  2.5324  2.2619  0.7789  
10   1.91  0.4314  2.5266  2.2619  0.7789  
11   1.91  0.4286  2.5266     NaN  0.7789  
12   1.91  0.4286  2.5266  2.2619  0.7789  
13   1.91  0.4314  2.5324  2.2671  0.7719  
14   1.90  0.4314  2.5324  2.2619  0.7860  
15   1.91  0.4286  2.5266  2.2619  0.7789  
16   1.90  0.4343  2.5266  2.2619  0.7789  
17   1.90  0.4343  2.5208     NaN  0.7789  
18   1.90  0.4314  2.5266  2.2619  0.7789  
19   1.90  0.4314  2.5324     NaN  0.7719  

[20 rows x 61 columns]
In [ ]:
Data.shape
Out[ ]:
(50012, 61)
In [ ]:
Data.columns
Out[ ]:
Index(['timestamp', 'AEFES', 'AKBNK', 'AKSA', 'AKSEN', 'ALARK', 'ALBRK',
       'ANACM', 'ARCLK', 'ASELS', 'ASUZU', 'AYGAZ', 'BAGFS', 'BANVT', 'BRISA',
       'CCOLA', 'CEMAS', 'ECILC', 'EREGL', 'FROTO', 'GARAN', 'GOODY', 'GUBRF',
       'HALKB', 'ICBCT', 'ISCTR', 'ISDMR', 'ISFIN', 'ISYAT', 'KAREL', 'KARSN',
       'KCHOL', 'KRDMB', 'KRDMD', 'MGROS', 'OTKAR', 'PARSN', 'PETKM', 'PGSUS',
       'PRKME', 'SAHOL', 'SASA', 'SISE', 'SKBNK', 'SODA', 'TCELL', 'THYAO',
       'TKFEN', 'TOASO', 'TRKCM', 'TSKB', 'TTKOM', 'TUKAS', 'TUPRS', 'USAK',
       'VAKBN', 'VESTL', 'YATAS', 'YKBNK', 'YUNSA', 'ZOREN'],
      dtype='object')
In [ ]:
Data_fill = Data.ffill()
Data_fill
Out[ ]:
timestamp AEFES AKBNK AKSA AKSEN ALARK ALBRK ANACM ARCLK ASELS ... TTKOM TUKAS TUPRS USAK VAKBN VESTL YATAS YKBNK YUNSA ZOREN
0 2012-09-17T06:45:00Z 22.3978 5.2084 1.7102 3.87 1.4683 1.1356 1.0634 6.9909 2.9948 ... 4.2639 0.96 29.8072 1.0382 3.8620 1.90 0.4172 2.5438 2.2619 0.7789
1 2012-09-17T07:00:00Z 22.3978 5.1938 1.7066 3.86 1.4574 1.1275 1.0634 6.9259 2.9948 ... 4.2521 0.96 29.7393 1.0382 3.8529 1.90 0.4229 2.5266 2.2462 0.7789
2 2012-09-17T07:15:00Z 22.3978 5.2084 1.7102 3.86 1.4610 1.1356 1.0679 6.9909 2.9855 ... 4.2521 0.97 29.6716 1.0463 3.8436 1.91 0.4229 2.5266 2.2566 0.7789
3 2012-09-17T07:30:00Z 22.3978 5.1938 1.7102 3.86 1.4537 1.1275 1.0679 6.9584 2.9855 ... 4.2521 0.97 29.7393 1.0382 3.8529 1.91 0.4286 2.5324 2.2619 0.7860
4 2012-09-17T07:45:00Z 22.5649 5.2084 1.7102 3.87 1.4574 1.1356 1.0725 6.9909 2.9760 ... 4.2521 0.97 29.8072 1.0382 3.8620 1.90 0.4286 2.5324 2.2619 0.7789
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
50007 2019-07-23T14:00:00Z 20.4800 7.7300 9.1400 2.47 3.2300 1.2100 2.8400 20.3000 18.1500 ... 5.6000 4.34 131.6000 1.0500 4.8600 9.98 5.3500 2.7500 4.2500 1.1700
50008 2019-07-23T14:15:00Z 20.5000 7.7200 9.1400 2.47 3.2200 1.2100 2.8400 20.3200 18.1500 ... 5.5700 4.35 131.5000 1.0500 4.8600 9.98 5.3400 2.7500 4.2400 1.1700
50009 2019-07-23T14:30:00Z 20.5000 7.7400 9.1300 2.46 3.2300 1.2100 2.8300 20.3400 18.1500 ... 5.5700 4.36 131.5000 1.0500 4.8600 9.96 5.3400 2.7600 4.2400 1.1700
50010 2019-07-23T14:45:00Z 20.4000 7.7000 9.1400 2.47 3.2400 1.2100 2.8200 20.3800 18.1500 ... 5.5700 4.35 131.3000 1.0400 4.8600 9.94 5.3400 2.7700 4.2400 1.1700
50011 2019-07-23T15:00:00Z 20.4600 7.7000 9.1400 2.47 3.2300 1.2000 2.8300 20.3200 18.1500 ... 5.5600 4.34 131.8000 1.0500 4.8500 9.93 5.3300 2.7700 4.2400 1.1700

50012 rows × 61 columns

In [ ]:
data = pd.DataFrame(Data_fill)

# Check for null values in the DataFrame
null_data = data.isnull().sum()

# Print out the columns with null values
print("Columns with Null Values:")
print(null_data[null_data > 0])
Columns with Null Values:
ISDMR    23955
PGSUS     3997
dtype: int64
In [ ]:
Data_filled = Data_fill.bfill()
Data_filled
Data_filled_timeless = Data_filled.drop(columns=['timestamp'])
Data_filled_timeless
Out[ ]:
AEFES AKBNK AKSA AKSEN ALARK ALBRK ANACM ARCLK ASELS ASUZU ... TTKOM TUKAS TUPRS USAK VAKBN VESTL YATAS YKBNK YUNSA ZOREN
0 22.3978 5.2084 1.7102 3.87 1.4683 1.1356 1.0634 6.9909 2.9948 2.4998 ... 4.2639 0.96 29.8072 1.0382 3.8620 1.90 0.4172 2.5438 2.2619 0.7789
1 22.3978 5.1938 1.7066 3.86 1.4574 1.1275 1.0634 6.9259 2.9948 2.5100 ... 4.2521 0.96 29.7393 1.0382 3.8529 1.90 0.4229 2.5266 2.2462 0.7789
2 22.3978 5.2084 1.7102 3.86 1.4610 1.1356 1.0679 6.9909 2.9855 2.4796 ... 4.2521 0.97 29.6716 1.0463 3.8436 1.91 0.4229 2.5266 2.2566 0.7789
3 22.3978 5.1938 1.7102 3.86 1.4537 1.1275 1.0679 6.9584 2.9855 2.4897 ... 4.2521 0.97 29.7393 1.0382 3.8529 1.91 0.4286 2.5324 2.2619 0.7860
4 22.5649 5.2084 1.7102 3.87 1.4574 1.1356 1.0725 6.9909 2.9760 2.4897 ... 4.2521 0.97 29.8072 1.0382 3.8620 1.90 0.4286 2.5324 2.2619 0.7789
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
50007 20.4800 7.7300 9.1400 2.47 3.2300 1.2100 2.8400 20.3000 18.1500 8.1300 ... 5.6000 4.34 131.6000 1.0500 4.8600 9.98 5.3500 2.7500 4.2500 1.1700
50008 20.5000 7.7200 9.1400 2.47 3.2200 1.2100 2.8400 20.3200 18.1500 8.0400 ... 5.5700 4.35 131.5000 1.0500 4.8600 9.98 5.3400 2.7500 4.2400 1.1700
50009 20.5000 7.7400 9.1300 2.46 3.2300 1.2100 2.8300 20.3400 18.1500 8.0900 ... 5.5700 4.36 131.5000 1.0500 4.8600 9.96 5.3400 2.7600 4.2400 1.1700
50010 20.4000 7.7000 9.1400 2.47 3.2400 1.2100 2.8200 20.3800 18.1500 7.9800 ... 5.5700 4.35 131.3000 1.0400 4.8600 9.94 5.3400 2.7700 4.2400 1.1700
50011 20.4600 7.7000 9.1400 2.47 3.2300 1.2000 2.8300 20.3200 18.1500 7.9700 ... 5.5600 4.34 131.8000 1.0500 4.8500 9.93 5.3300 2.7700 4.2400 1.1700

50012 rows × 60 columns

In [ ]:
data = pd.DataFrame(Data_filled)

# Check for null values in the DataFrame
null_data = data.isnull().sum()

# Print out the columns with null values
print("Columns with Null Values:")
print(null_data[null_data > 0])
Columns with Null Values:
Series([], dtype: int64)

As we can see we filled all our data that were empthy first with forward fill then there were lack of data as well we did backward fill

In [ ]:
Data_filled['timestamp'] = pd.to_datetime(Data_filled['timestamp'], format="%Y-%m-%dT%H:%M:%SZ")
print(Data_filled)
                timestamp    AEFES   AKBNK    AKSA  AKSEN   ALARK   ALBRK  \
0     2012-09-17 06:45:00  22.3978  5.2084  1.7102   3.87  1.4683  1.1356   
1     2012-09-17 07:00:00  22.3978  5.1938  1.7066   3.86  1.4574  1.1275   
2     2012-09-17 07:15:00  22.3978  5.2084  1.7102   3.86  1.4610  1.1356   
3     2012-09-17 07:30:00  22.3978  5.1938  1.7102   3.86  1.4537  1.1275   
4     2012-09-17 07:45:00  22.5649  5.2084  1.7102   3.87  1.4574  1.1356   
...                   ...      ...     ...     ...    ...     ...     ...   
50007 2019-07-23 14:00:00  20.4800  7.7300  9.1400   2.47  3.2300  1.2100   
50008 2019-07-23 14:15:00  20.5000  7.7200  9.1400   2.47  3.2200  1.2100   
50009 2019-07-23 14:30:00  20.5000  7.7400  9.1300   2.46  3.2300  1.2100   
50010 2019-07-23 14:45:00  20.4000  7.7000  9.1400   2.47  3.2400  1.2100   
50011 2019-07-23 15:00:00  20.4600  7.7000  9.1400   2.47  3.2300  1.2000   

        ANACM    ARCLK    ASELS  ...   TTKOM  TUKAS     TUPRS    USAK   VAKBN  \
0      1.0634   6.9909   2.9948  ...  4.2639   0.96   29.8072  1.0382  3.8620   
1      1.0634   6.9259   2.9948  ...  4.2521   0.96   29.7393  1.0382  3.8529   
2      1.0679   6.9909   2.9855  ...  4.2521   0.97   29.6716  1.0463  3.8436   
3      1.0679   6.9584   2.9855  ...  4.2521   0.97   29.7393  1.0382  3.8529   
4      1.0725   6.9909   2.9760  ...  4.2521   0.97   29.8072  1.0382  3.8620   
...       ...      ...      ...  ...     ...    ...       ...     ...     ...   
50007  2.8400  20.3000  18.1500  ...  5.6000   4.34  131.6000  1.0500  4.8600   
50008  2.8400  20.3200  18.1500  ...  5.5700   4.35  131.5000  1.0500  4.8600   
50009  2.8300  20.3400  18.1500  ...  5.5700   4.36  131.5000  1.0500  4.8600   
50010  2.8200  20.3800  18.1500  ...  5.5700   4.35  131.3000  1.0400  4.8600   
50011  2.8300  20.3200  18.1500  ...  5.5600   4.34  131.8000  1.0500  4.8500   

       VESTL   YATAS   YKBNK   YUNSA   ZOREN  
0       1.90  0.4172  2.5438  2.2619  0.7789  
1       1.90  0.4229  2.5266  2.2462  0.7789  
2       1.91  0.4229  2.5266  2.2566  0.7789  
3       1.91  0.4286  2.5324  2.2619  0.7860  
4       1.90  0.4286  2.5324  2.2619  0.7789  
...      ...     ...     ...     ...     ...  
50007   9.98  5.3500  2.7500  4.2500  1.1700  
50008   9.98  5.3400  2.7500  4.2400  1.1700  
50009   9.96  5.3400  2.7600  4.2400  1.1700  
50010   9.94  5.3400  2.7700  4.2400  1.1700  
50011   9.93  5.3300  2.7700  4.2400  1.1700  

[50012 rows x 61 columns]
In [ ]:
# Set the 'timestamp' column as the index
Data_filled.set_index('timestamp', inplace=True)

# Resample the DataFrame by month and apply an aggregation function (e.g., mean)
Data_aggregated = Data_filled.resample('M').mean()

# Reset the index to make 'timestamp' a column again
Data_aggregated.reset_index(inplace=True)

# Display the aggregated DataFrame
Data_aggregated
Out[ ]:
timestamp AEFES AKBNK AKSA AKSEN ALARK ALBRK ANACM ARCLK ASELS ... TTKOM TUKAS TUPRS USAK VAKBN VESTL YATAS YKBNK YUNSA ZOREN
0 2012-09-30 21.990191 5.123117 1.682904 3.866231 1.419293 1.127155 1.091068 6.575133 2.997942 ... 4.191370 0.954192 28.731524 1.046830 3.710068 1.899769 0.413282 2.498152 2.320318 0.766005
1 2012-10-31 22.436759 5.789223 1.694708 3.698123 1.448755 1.106620 1.150508 6.661405 3.165903 ... 5.483872 0.922549 28.362370 1.197415 3.709942 1.822332 0.344528 2.573235 2.554721 0.741018
2 2012-11-30 21.613061 6.053151 1.730948 3.574476 1.487183 1.202658 1.209599 7.061526 3.155719 ... 5.201549 0.904545 30.145567 1.132350 3.984920 1.786031 0.337622 2.670650 2.765547 0.735518
3 2012-12-31 21.535772 6.349386 1.836533 4.074751 1.667173 1.370815 1.241861 7.238860 3.610114 ... 5.372824 0.930110 33.895264 1.127946 4.297170 1.868803 0.340183 2.966750 2.708904 0.773274
4 2013-01-31 22.277677 6.776285 1.959165 4.631329 1.942940 1.535015 1.358492 7.907567 3.921994 ... 5.784868 0.953549 34.748862 1.146736 4.914509 2.025717 0.343421 3.194934 2.621166 1.008381
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
78 2019-03-31 19.600504 6.507827 8.201133 2.787143 2.653300 1.688616 3.023953 19.270402 22.756085 ... 5.066548 4.134747 131.386789 1.094851 5.148720 12.073155 5.450997 2.168452 4.942154 1.410863
79 2019-04-30 18.934514 6.263428 8.581837 2.438346 2.493987 1.505261 2.933529 18.108465 21.095927 ... 4.406379 3.959702 129.464978 1.023115 4.319568 12.994531 4.849076 2.147139 4.430529 1.276274
80 2019-05-31 17.964252 5.769545 8.199104 2.238094 2.717440 1.243186 2.742019 16.493457 18.234517 ... 4.225021 3.655647 120.396017 0.990413 3.675861 9.969360 4.025533 1.947127 3.965989 1.156245
81 2019-06-30 19.361205 6.487419 9.108642 2.326004 3.151472 1.146711 2.800497 18.380019 18.156903 ... 4.805430 5.031530 119.014340 1.027648 3.876272 11.013518 4.427476 2.243652 4.295201 1.170459
82 2019-07-31 20.240195 7.410547 8.985977 2.393125 3.173809 1.196523 2.822285 19.732930 17.930801 ... 5.328398 4.403008 121.140430 1.042051 4.734668 10.519551 4.880820 2.605449 4.310781 1.195703

83 rows × 61 columns

In [ ]:
Data_aggregated['year_month'] = Data_aggregated['timestamp'].dt.strftime('%Y-%m')
Data_aggregated = Data_aggregated.drop(columns=['timestamp'])

# Display the DataFrame with the new 'year_month' and 'date' columns
print(Data_aggregated)
        AEFES     AKBNK      AKSA     AKSEN     ALARK     ALBRK     ANACM  \
0   21.990191  5.123117  1.682904  3.866231  1.419293  1.127155  1.091068   
1   22.436759  5.789223  1.694708  3.698123  1.448755  1.106620  1.150508   
2   21.613061  6.053151  1.730948  3.574476  1.487183  1.202658  1.209599   
3   21.535772  6.349386  1.836533  4.074751  1.667173  1.370815  1.241861   
4   22.277677  6.776285  1.959165  4.631329  1.942940  1.535015  1.358492   
..        ...       ...       ...       ...       ...       ...       ...   
78  19.600504  6.507827  8.201133  2.787143  2.653300  1.688616  3.023953   
79  18.934514  6.263428  8.581837  2.438346  2.493987  1.505261  2.933529   
80  17.964252  5.769545  8.199104  2.238094  2.717440  1.243186  2.742019   
81  19.361205  6.487419  9.108642  2.326004  3.151472  1.146711  2.800497   
82  20.240195  7.410547  8.985977  2.393125  3.173809  1.196523  2.822285   

        ARCLK      ASELS     ASUZU  ...     TUKAS       TUPRS      USAK  \
0    6.575133   2.997942  2.446388  ...  0.954192   28.731524  1.046830   
1    6.661405   3.165903  3.254486  ...  0.922549   28.362370  1.197415   
2    7.061526   3.155719  3.982953  ...  0.904545   30.145567  1.132350   
3    7.238860   3.610114  4.233941  ...  0.930110   33.895264  1.127946   
4    7.907567   3.921994  4.286279  ...  0.953549   34.748862  1.146736   
..        ...        ...       ...  ...       ...         ...       ...   
78  19.270402  22.756085  7.825997  ...  4.134747  131.386789  1.094851   
79  18.108465  21.095927  7.528018  ...  3.959702  129.464978  1.023115   
80  16.493457  18.234517  7.159844  ...  3.655647  120.396017  0.990413   
81  18.380019  18.156903  6.947476  ...  5.031530  119.014340  1.027648   
82  19.732930  17.930801  7.255117  ...  4.403008  121.140430  1.042051   

       VAKBN      VESTL     YATAS     YKBNK     YUNSA     ZOREN  year_month  
0   3.710068   1.899769  0.413282  2.498152  2.320318  0.766005     2012-09  
1   3.709942   1.822332  0.344528  2.573235  2.554721  0.741018     2012-10  
2   3.984920   1.786031  0.337622  2.670650  2.765547  0.735518     2012-11  
3   4.297170   1.868803  0.340183  2.966750  2.708904  0.773274     2012-12  
4   4.914509   2.025717  0.343421  3.194934  2.621166  1.008381     2013-01  
..       ...        ...       ...       ...       ...       ...         ...  
78  5.148720  12.073155  5.450997  2.168452  4.942154  1.410863     2019-03  
79  4.319568  12.994531  4.849076  2.147139  4.430529  1.276274     2019-04  
80  3.675861   9.969360  4.025533  1.947127  3.965989  1.156245     2019-05  
81  3.876272  11.013518  4.427476  2.243652  4.295201  1.170459     2019-06  
82  4.734668  10.519551  4.880820  2.605449  4.310781  1.195703     2019-07  

[83 rows x 61 columns]
In [ ]:
Data_aggregated = Data_aggregated[['year_month'] + [col for col in Data_aggregated if col != 'year_month']]

# Display the modified DataFrame
print(Data_aggregated)
   year_month      AEFES     AKBNK      AKSA     AKSEN     ALARK     ALBRK  \
0     2012-09  21.990191  5.123117  1.682904  3.866231  1.419293  1.127155   
1     2012-10  22.436759  5.789223  1.694708  3.698123  1.448755  1.106620   
2     2012-11  21.613061  6.053151  1.730948  3.574476  1.487183  1.202658   
3     2012-12  21.535772  6.349386  1.836533  4.074751  1.667173  1.370815   
4     2013-01  22.277677  6.776285  1.959165  4.631329  1.942940  1.535015   
..        ...        ...       ...       ...       ...       ...       ...   
78    2019-03  19.600504  6.507827  8.201133  2.787143  2.653300  1.688616   
79    2019-04  18.934514  6.263428  8.581837  2.438346  2.493987  1.505261   
80    2019-05  17.964252  5.769545  8.199104  2.238094  2.717440  1.243186   
81    2019-06  19.361205  6.487419  9.108642  2.326004  3.151472  1.146711   
82    2019-07  20.240195  7.410547  8.985977  2.393125  3.173809  1.196523   

       ANACM      ARCLK      ASELS  ...     TTKOM     TUKAS       TUPRS  \
0   1.091068   6.575133   2.997942  ...  4.191370  0.954192   28.731524   
1   1.150508   6.661405   3.165903  ...  5.483872  0.922549   28.362370   
2   1.209599   7.061526   3.155719  ...  5.201549  0.904545   30.145567   
3   1.241861   7.238860   3.610114  ...  5.372824  0.930110   33.895264   
4   1.358492   7.907567   3.921994  ...  5.784868  0.953549   34.748862   
..       ...        ...        ...  ...       ...       ...         ...   
78  3.023953  19.270402  22.756085  ...  5.066548  4.134747  131.386789   
79  2.933529  18.108465  21.095927  ...  4.406379  3.959702  129.464978   
80  2.742019  16.493457  18.234517  ...  4.225021  3.655647  120.396017   
81  2.800497  18.380019  18.156903  ...  4.805430  5.031530  119.014340   
82  2.822285  19.732930  17.930801  ...  5.328398  4.403008  121.140430   

        USAK     VAKBN      VESTL     YATAS     YKBNK     YUNSA     ZOREN  
0   1.046830  3.710068   1.899769  0.413282  2.498152  2.320318  0.766005  
1   1.197415  3.709942   1.822332  0.344528  2.573235  2.554721  0.741018  
2   1.132350  3.984920   1.786031  0.337622  2.670650  2.765547  0.735518  
3   1.127946  4.297170   1.868803  0.340183  2.966750  2.708904  0.773274  
4   1.146736  4.914509   2.025717  0.343421  3.194934  2.621166  1.008381  
..       ...       ...        ...       ...       ...       ...       ...  
78  1.094851  5.148720  12.073155  5.450997  2.168452  4.942154  1.410863  
79  1.023115  4.319568  12.994531  4.849076  2.147139  4.430529  1.276274  
80  0.990413  3.675861   9.969360  4.025533  1.947127  3.965989  1.156245  
81  1.027648  3.876272  11.013518  4.427476  2.243652  4.295201  1.170459  
82  1.042051  4.734668  10.519551  4.880820  2.605449  4.310781  1.195703  

[83 rows x 61 columns]
In [ ]:
Data_timeless = Data_aggregated.drop(columns=['year_month'])
print(Data_timeless)
        AEFES     AKBNK      AKSA     AKSEN     ALARK     ALBRK     ANACM  \
0   21.990191  5.123117  1.682904  3.866231  1.419293  1.127155  1.091068   
1   22.436759  5.789223  1.694708  3.698123  1.448755  1.106620  1.150508   
2   21.613061  6.053151  1.730948  3.574476  1.487183  1.202658  1.209599   
3   21.535772  6.349386  1.836533  4.074751  1.667173  1.370815  1.241861   
4   22.277677  6.776285  1.959165  4.631329  1.942940  1.535015  1.358492   
..        ...       ...       ...       ...       ...       ...       ...   
78  19.600504  6.507827  8.201133  2.787143  2.653300  1.688616  3.023953   
79  18.934514  6.263428  8.581837  2.438346  2.493987  1.505261  2.933529   
80  17.964252  5.769545  8.199104  2.238094  2.717440  1.243186  2.742019   
81  19.361205  6.487419  9.108642  2.326004  3.151472  1.146711  2.800497   
82  20.240195  7.410547  8.985977  2.393125  3.173809  1.196523  2.822285   

        ARCLK      ASELS     ASUZU  ...     TTKOM     TUKAS       TUPRS  \
0    6.575133   2.997942  2.446388  ...  4.191370  0.954192   28.731524   
1    6.661405   3.165903  3.254486  ...  5.483872  0.922549   28.362370   
2    7.061526   3.155719  3.982953  ...  5.201549  0.904545   30.145567   
3    7.238860   3.610114  4.233941  ...  5.372824  0.930110   33.895264   
4    7.907567   3.921994  4.286279  ...  5.784868  0.953549   34.748862   
..        ...        ...       ...  ...       ...       ...         ...   
78  19.270402  22.756085  7.825997  ...  5.066548  4.134747  131.386789   
79  18.108465  21.095927  7.528018  ...  4.406379  3.959702  129.464978   
80  16.493457  18.234517  7.159844  ...  4.225021  3.655647  120.396017   
81  18.380019  18.156903  6.947476  ...  4.805430  5.031530  119.014340   
82  19.732930  17.930801  7.255117  ...  5.328398  4.403008  121.140430   

        USAK     VAKBN      VESTL     YATAS     YKBNK     YUNSA     ZOREN  
0   1.046830  3.710068   1.899769  0.413282  2.498152  2.320318  0.766005  
1   1.197415  3.709942   1.822332  0.344528  2.573235  2.554721  0.741018  
2   1.132350  3.984920   1.786031  0.337622  2.670650  2.765547  0.735518  
3   1.127946  4.297170   1.868803  0.340183  2.966750  2.708904  0.773274  
4   1.146736  4.914509   2.025717  0.343421  3.194934  2.621166  1.008381  
..       ...       ...        ...       ...       ...       ...       ...  
78  1.094851  5.148720  12.073155  5.450997  2.168452  4.942154  1.410863  
79  1.023115  4.319568  12.994531  4.849076  2.147139  4.430529  1.276274  
80  0.990413  3.675861   9.969360  4.025533  1.947127  3.965989  1.156245  
81  1.027648  3.876272  11.013518  4.427476  2.243652  4.295201  1.170459  
82  1.042051  4.734668  10.519551  4.880820  2.605449  4.310781  1.195703  

[83 rows x 60 columns]

Now we have a data of means of the data for every month

In [ ]:
plt.figure(figsize=(16, 6))  
plt.boxplot(Data_filled_timeless.iloc[:, :30])
plt.title('Box Plot of the First 30 Columns')
plt.ylabel('Values')
plt.xticks(range(1, 31), Data_filled_timeless.columns[:30], rotation=45)


plt.show()
No description has been provided for this image
In [ ]:
plt.figure(figsize=(16, 6))  
plt.boxplot(Data_filled_timeless.iloc[:, 30:60])
plt.title('Box Plot of the First 30 Columns')
plt.ylabel('Values')
plt.xticks(range(1, 31), Data_filled_timeless.columns[30:60], rotation=45)


plt.show()
No description has been provided for this image
In [ ]:
 
In [ ]:
import pandas as pd
import matplotlib.pyplot as plt
from pandas.plotting import scatter_matrix

# Create a scatter plot matrix
scatter_matrix(Data_aggregated.iloc[:, :20], alpha=0.7, figsize=(16, 16), diagonal='scatter', marker='*', s=20)

# Show the plot
plt.show()
No description has been provided for this image
In [ ]:
import pandas as pd
import matplotlib.pyplot as plt
from pandas.plotting import scatter_matrix

# Create a scatter plot matrix
scatter_matrix(Data_aggregated.iloc[:, 20:40], alpha=0.7, figsize=(16, 16), diagonal='scatter', marker='*', s=20)

# Show the plot
plt.show()
No description has been provided for this image
In [ ]:
import pandas as pd
import matplotlib.pyplot as plt
from pandas.plotting import scatter_matrix

# Create a scatter plot matrix
scatter_matrix(Data_aggregated.iloc[:, 40:60], alpha=0.7, figsize=(16, 16), diagonal='scatter', marker='*', s=20)

# Show the plot
plt.show()
No description has been provided for this image
In [ ]:
from sklearn.preprocessing import StandardScaler



# Standardizing the features
x = StandardScaler().fit_transform(Data_filled_timeless)

x
Out[ ]:
array([[ 0.56197627, -1.33921203, -1.98020843, ..., -0.05094032,
        -1.34238383, -1.50443231],
       [ 0.56197627, -1.35467319, -1.98153131, ..., -0.09157655,
        -1.35420384, -1.50443231],
       [ 0.56197627, -1.33921203, -1.98020843, ..., -0.09157655,
        -1.34637402, -1.50443231],
       ...,
       [-0.20089575,  1.34171073,  0.74633474, ...,  0.45984767,
         0.14686271, -0.2469157 ],
       [-0.24109346,  1.29935139,  0.75000942, ...,  0.48347338,
         0.14686271, -0.2469157 ],
       [-0.21697484,  1.29935139,  0.75000942, ...,  0.48347338,
         0.14686271, -0.2469157 ]])
In [ ]:
from sklearn.decomposition import PCA
import pandas as pd

# Assuming 'data' is your dataset in a DataFrame
# You may need to import your data or load it into a DataFrame first

# Create a PCA instance
pca = PCA()


# Fit the PCA model to your data
pca.fit(x)

# Access the principal components
principal_components = pca.components_

# Access the explained variance ratio
explained_variance_ratio = pca.explained_variance_ratio_

# Access the transformed data in the reduced-dimensional space
reduced_data = pca.transform(x)

principal_components_df = pd.DataFrame(principal_components, columns=Data_filled_timeless.columns)

# Print the explained variance ratios and other results
print("Explained Variance Ratios:", explained_variance_ratio)
print("Principal Components:")
print(principal_components_df)

principal_components_df.describe()
Explained Variance Ratios: [5.08161620e-01 1.72173999e-01 1.07036622e-01 5.26516811e-02
 3.77558398e-02 2.22998159e-02 1.48154966e-02 1.05226469e-02
 8.76264156e-03 7.91401044e-03 7.80436702e-03 5.90209605e-03
 5.31206348e-03 4.78873196e-03 4.07541952e-03 3.08398657e-03
 2.85847008e-03 2.35816495e-03 2.26781853e-03 1.84016348e-03
 1.62798946e-03 1.39864269e-03 1.23118844e-03 1.14567057e-03
 1.06012036e-03 9.56509144e-04 9.25888904e-04 8.28669066e-04
 7.58614254e-04 7.11463496e-04 6.41663807e-04 6.25022120e-04
 5.44808636e-04 4.91443567e-04 4.74218174e-04 4.10873407e-04
 3.67232165e-04 3.31319819e-04 3.03756311e-04 2.78376104e-04
 2.42286021e-04 2.33821089e-04 2.17302916e-04 1.90787417e-04
 1.81561520e-04 1.76884660e-04 1.59245465e-04 1.39229923e-04
 1.26770733e-04 1.22837581e-04 1.02928874e-04 1.01210801e-04
 8.81089800e-05 7.97517563e-05 7.32229303e-05 6.76980510e-05
 6.15300486e-05 5.28496921e-05 4.44996001e-05 3.83464653e-05]
Principal Components:
       AEFES     AKBNK      AKSA     AKSEN     ALARK     ALBRK     ANACM  \
0  -0.007980 -0.109782 -0.160248 -0.064074 -0.136015 -0.005687 -0.167441   
1  -0.163360 -0.215924 -0.037105 -0.161635 -0.086260 -0.113613  0.053168   
2  -0.266222  0.073665  0.072071 -0.150605 -0.105502 -0.213452 -0.089453   
3  -0.012454  0.088737 -0.081155  0.242470  0.127080 -0.238392  0.090205   
4   0.018235 -0.114467  0.065370  0.221813 -0.248909 -0.086165 -0.014644   
5   0.013746  0.090637 -0.204370  0.227620 -0.138482  0.236587  0.100457   
6   0.046536  0.104690 -0.156258  0.075031 -0.130110  0.356248  0.031835   
7  -0.062397 -0.059552 -0.083249 -0.065110  0.002339  0.183951 -0.050151   
8  -0.141586 -0.005794 -0.090440 -0.121614  0.127169  0.017123 -0.046635   
9  -0.490462 -0.098407  0.103404  0.139423  0.057129  0.455893  0.043175   
10  0.252593  0.043546 -0.019556 -0.107833  0.006761  0.044339 -0.042606   
11  0.398288 -0.114306  0.229760 -0.015136 -0.040758  0.240643  0.014510   
12  0.054940  0.092651  0.013326  0.090902  0.070449  0.221957  0.048859   
13 -0.023586  0.071863  0.030764  0.000643 -0.078045 -0.102378 -0.086870   
14  0.290620 -0.178166  0.017142  0.168270  0.153440 -0.127168  0.080901   
15 -0.174766 -0.066569 -0.058621  0.351734  0.172384 -0.001223  0.074665   
16 -0.237653  0.054206  0.151106 -0.017945  0.036810  0.134385 -0.082897   
17 -0.119240  0.123907  0.094738 -0.043193 -0.211459 -0.149597  0.055216   
18 -0.106737 -0.013408 -0.068518 -0.164402  0.197432  0.048584  0.004462   
19  0.086876 -0.013558  0.198012  0.230285  0.074334 -0.184026  0.066233   
20 -0.103577 -0.042103 -0.002216  0.164725 -0.030529 -0.230344 -0.050055   
21 -0.033171 -0.029061  0.145820 -0.151416  0.141231  0.178515 -0.056544   
22 -0.023930 -0.064378 -0.061570  0.088857 -0.080405  0.061280 -0.080529   
23  0.089714 -0.084382 -0.128715  0.096356  0.152588  0.140798  0.096297   
24 -0.218573 -0.045642  0.016480  0.358492  0.100194 -0.057686 -0.105803   
25 -0.078896 -0.034468 -0.268855 -0.004037 -0.106579 -0.016943 -0.185855   
26 -0.079512 -0.029437  0.114540 -0.195168 -0.042869  0.060298 -0.113005   
27  0.095551  0.049855 -0.117157  0.006708  0.138424  0.126659 -0.075284   
28 -0.069165 -0.014021  0.058743 -0.037371  0.153435 -0.116877  0.034848   
29  0.099154  0.032333  0.088268  0.034056 -0.043425  0.214867 -0.032360   
30  0.092289  0.122357 -0.004112 -0.071244  0.026170  0.020585 -0.071986   
31 -0.116272  0.298741 -0.157126 -0.089497  0.197164 -0.018129 -0.003194   
32  0.161904 -0.015489  0.046540  0.104489  0.194566  0.059587  0.048334   
33 -0.034435 -0.049354  0.226528 -0.001603  0.266981 -0.019731 -0.012422   
34 -0.032339 -0.203601  0.074198 -0.037975  0.076530  0.130576 -0.014349   
35 -0.043029 -0.150657 -0.152786 -0.081847  0.074188 -0.087437 -0.126986   
36  0.094080  0.129498  0.148125 -0.123118 -0.137486  0.025714 -0.095301   
37 -0.047891 -0.086916  0.032559  0.153212 -0.190216  0.006308 -0.036765   
38 -0.081788  0.119605  0.038598 -0.081180 -0.152540  0.076428  0.055982   
39  0.013685 -0.240582 -0.358315 -0.097959 -0.136889  0.012546  0.193490   
40  0.073173  0.082066 -0.106478  0.166873  0.034625  0.004663 -0.063419   
41 -0.018417  0.106382  0.118922  0.245174 -0.398400  0.031417  0.125245   
42 -0.020601 -0.012522  0.106616 -0.034848 -0.107145 -0.029777  0.040650   
43  0.009678 -0.046663 -0.081538 -0.140324 -0.090104 -0.023108  0.047884   
44 -0.049333 -0.094562 -0.019594  0.108383 -0.037620  0.012545 -0.137163   
45 -0.042417 -0.165193  0.223127 -0.104191 -0.225101  0.041299  0.237291   
46  0.045367 -0.119475 -0.236521 -0.025069 -0.033796 -0.007031 -0.145130   
47 -0.012400  0.445732 -0.021605 -0.010897 -0.022088 -0.037872  0.280470   
48  0.043821 -0.246241 -0.088447  0.027792 -0.054947 -0.002329 -0.156569   
49 -0.064905 -0.052587  0.006902 -0.087175  0.180114 -0.033752  0.384111   
50 -0.076102 -0.041409  0.064562 -0.045402  0.090912 -0.002573  0.208728   
51  0.044306  0.293247 -0.068782  0.024161 -0.015038  0.055450 -0.142142   
52 -0.003329 -0.236209  0.181565  0.020625  0.006643  0.013881 -0.032606   
53  0.003627 -0.065158  0.088379  0.012145 -0.086507 -0.023126 -0.014856   
54 -0.030430 -0.027024  0.027586  0.036508 -0.037301  0.026851  0.203007   
55  0.011262 -0.137636 -0.095042 -0.110401 -0.007297 -0.023207  0.362293   
56  0.022951  0.030469  0.291200 -0.013956  0.080818 -0.004149 -0.280136   
57 -0.031590  0.091071 -0.003292 -0.010074 -0.038375  0.000002 -0.054748   
58 -0.006653 -0.004936  0.127871 -0.022522 -0.046528  0.007288  0.076089   
59  0.018140  0.002061  0.020201  0.085012  0.027467  0.012455 -0.196110   

       ARCLK     ASELS     ASUZU  ...     TTKOM     TUKAS     TUPRS      USAK  \
0  -0.121985 -0.174066 -0.148688  ...  0.014811 -0.118634 -0.167450 -0.127121   
1  -0.037722 -0.002479 -0.093872  ... -0.267321  0.064886  0.090332 -0.146461   
2   0.251883  0.003305 -0.130939  ...  0.109217  0.075216 -0.008250  0.082809   
3   0.016899  0.092176 -0.081544  ... -0.116369 -0.123644  0.035795  0.182279   
4  -0.139251  0.054779  0.110167  ... -0.051142 -0.278016 -0.067371  0.070142   
5  -0.156691 -0.067034 -0.008158  ...  0.011407  0.244813  0.096003 -0.051961   
6   0.117616 -0.035796 -0.078856  ... -0.093147 -0.319786 -0.007234 -0.158478   
7  -0.027768  0.158099 -0.097405  ... -0.166857  0.000148  0.152530  0.195655   
8   0.008805 -0.035204 -0.033747  ... -0.099325  0.029306 -0.040667 -0.041011   
9   0.058162  0.010423  0.017911  ...  0.102478  0.120533  0.013823  0.165521   
10  0.002190  0.086554  0.158284  ...  0.009098 -0.117089 -0.065234 -0.201846   
11  0.146672 -0.027253 -0.070888  ...  0.119636  0.158263  0.045954  0.020608   
12 -0.011101 -0.032525 -0.007682  ... -0.042926  0.155310  0.023059 -0.145730   
13 -0.021945 -0.059522 -0.038515  ...  0.298005  0.318998  0.068022  0.100003   
14 -0.157707  0.018938  0.200411  ... -0.202992  0.176235  0.027405  0.027677   
15 -0.050355  0.046369 -0.023416  ...  0.163381 -0.177351  0.001254 -0.129106   
16 -0.032519 -0.019776  0.229598  ... -0.312883 -0.076201 -0.019080  0.107280   
17 -0.074661 -0.042405 -0.116558  ...  0.150333 -0.119797 -0.084785  0.063964   
18 -0.113103  0.060740  0.024416  ...  0.175867  0.015732  0.067978 -0.180499   
19  0.053169 -0.121784  0.160763  ... -0.032275  0.120693 -0.071167  0.046497   
20  0.012995  0.021370 -0.150004  ... -0.089428  0.225902  0.043832 -0.201883   
21 -0.061836  0.040865 -0.005719  ...  0.078856  0.001594  0.010191  0.169478   
22 -0.105494 -0.104355  0.060496  ...  0.043259 -0.182544  0.139812 -0.059038   
23 -0.025420  0.024902  0.015214  ...  0.332803  0.020109 -0.095889  0.032379   
24 -0.005684  0.107308  0.036603  ... -0.181447  0.167523 -0.042994 -0.291118   
25 -0.006980  0.097022  0.207756  ...  0.141815  0.198478  0.077229 -0.011382   
26 -0.096189  0.028964 -0.120010  ... -0.184632 -0.056557  0.054183 -0.192684   
27  0.039289 -0.004979  0.357246  ...  0.020729 -0.133382 -0.095186  0.056569   
28 -0.157238  0.088972  0.246306  ... -0.152781 -0.091684  0.055295 -0.045549   
29  0.150349 -0.035627 -0.043632  ... -0.314532  0.279212 -0.113390 -0.059879   
30 -0.072445  0.097365 -0.228987  ... -0.167041  0.091305  0.088248 -0.004817   
31  0.126895 -0.038264  0.014129  ...  0.022399 -0.034654 -0.137838 -0.139486   
32 -0.052102  0.003361 -0.368007  ... -0.034183 -0.082714  0.150591  0.031888   
33 -0.170432 -0.179605 -0.192678  ...  0.177160 -0.068923 -0.009264 -0.201970   
34 -0.026762 -0.172558  0.036741  ... -0.137827  0.026751 -0.062312 -0.054437   
35  0.266634 -0.179797  0.187998  ... -0.072940  0.072854  0.080478  0.175964   
36 -0.090248  0.063587  0.056241  ...  0.051163  0.084663 -0.028202 -0.115303   
37  0.073556  0.060822 -0.041658  ...  0.138248  0.069669 -0.005181 -0.073930   
38 -0.368540  0.010280  0.039945  ... -0.089156  0.010563  0.003471  0.205118   
39 -0.160937  0.187136 -0.151094  ... -0.074583  0.094693 -0.133336  0.189209   
40  0.199512 -0.076169 -0.315304  ... -0.172235  0.011361 -0.363459  0.231488   
41  0.026843 -0.008452  0.033991  ... -0.022194 -0.126015  0.140751 -0.066165   
42 -0.328206 -0.161748  0.107572  ...  0.033864  0.238222 -0.068057  0.111253   
43  0.097695 -0.144801 -0.006187  ... -0.090136  0.014459  0.012503 -0.328712   
44  0.219642 -0.058193  0.070539  ...  0.039301  0.005732  0.138703 -0.003097   
45  0.233217 -0.064022  0.154013  ...  0.046195 -0.006060 -0.167598 -0.155450   
46  0.004729 -0.030258  0.021480  ...  0.062212  0.064609  0.060513 -0.142423   
47  0.181951  0.022239  0.059624  ... -0.045789  0.057295  0.124739 -0.006246   
48  0.039394 -0.170829 -0.029238  ...  0.010925 -0.145140  0.033763  0.069969   
49  0.029587 -0.325030  0.010858  ... -0.037730 -0.046222 -0.032723  0.060118   
50 -0.147947  0.166320 -0.077758  ...  0.037176  0.001383 -0.119270 -0.124540   
51 -0.128701  0.170248  0.067385  ... -0.007973  0.018115  0.005525 -0.078353   
52  0.115073  0.510842 -0.034684  ...  0.069693 -0.018346 -0.270246 -0.058571   
53 -0.047663 -0.106092 -0.084357  ... -0.001940 -0.110906  0.174928  0.087482   
54 -0.026332 -0.155929 -0.095363  ... -0.009182  0.086903  0.076031 -0.067443   
55  0.222440  0.294053  0.056792  ... -0.023089 -0.027065  0.226085  0.029056   
56  0.078821  0.163170 -0.060059  ... -0.033767 -0.056967  0.234714  0.100450   
57 -0.022305  0.010785  0.039699  ... -0.018095  0.038322 -0.524948  0.029787   
58 -0.045541 -0.032359  0.042616  ... -0.028170 -0.053236 -0.133797  0.026259   
59  0.055713 -0.181822 -0.004274  ... -0.028624 -0.058733 -0.013943  0.064094   

       VAKBN     VESTL     YATAS     YKBNK     YUNSA     ZOREN  
0  -0.091523 -0.155937 -0.170246  0.040731 -0.090133 -0.128231  
1  -0.252428  0.029923 -0.021708 -0.276577 -0.002581 -0.101419  
2   0.020593  0.088437 -0.054690 -0.056988 -0.261302  0.071353  
3   0.068797 -0.127410  0.046546 -0.016966 -0.191355 -0.179605  
4  -0.109615 -0.004296  0.009768 -0.117349  0.172310  0.177517  
5   0.034825  0.131749 -0.000281  0.107032 -0.045935  0.129620  
6   0.104957  0.008277 -0.130782  0.079254  0.080813  0.053028  
7  -0.030276 -0.242449 -0.047347 -0.152976 -0.116805 -0.125377  
8  -0.010873  0.231568 -0.011289  0.170651 -0.072666  0.188148  
9   0.056035 -0.015384 -0.018328 -0.125948 -0.027069  0.088380  
10  0.034333  0.003343  0.277842 -0.072837 -0.328214  0.198714  
11  0.016276 -0.087233  0.044541 -0.103171 -0.031864 -0.334004  
12 -0.052718 -0.166360 -0.096745 -0.004224 -0.141290 -0.091752  
13 -0.037000  0.053339 -0.027097  0.120543 -0.026765 -0.043181  
14 -0.090321  0.098343 -0.119396 -0.047214  0.056648 -0.170199  
15 -0.098574 -0.216888 -0.065832 -0.018810  0.018909  0.097933  
16  0.096086  0.024216 -0.007343  0.213793 -0.035681 -0.362043  
17  0.072109 -0.328973  0.131269 -0.088546  0.149915 -0.220823  
18 -0.086051  0.117552  0.129074  0.122633  0.337128 -0.208160  
19  0.001348  0.064859 -0.175265 -0.105053 -0.115877  0.223653  
20  0.096298 -0.079894  0.024639 -0.058933  0.301662  0.050979  
21 -0.107210 -0.096119  0.051227  0.252002  0.176099  0.252600  
22 -0.000215 -0.005256 -0.088782 -0.012186 -0.389764 -0.040430  
23 -0.165630 -0.032096  0.093337 -0.191345 -0.035555 -0.163388  
24  0.144576 -0.022360  0.200601  0.117581 -0.102202 -0.221061  
25  0.074675 -0.235003  0.069967 -0.127938 -0.095726  0.096852  
26 -0.133178  0.041160  0.114924 -0.205878  0.096481  0.018871  
27  0.215783  0.045288 -0.123733 -0.073126  0.280705 -0.068823  
28  0.015686 -0.175472 -0.023532  0.101465  0.016646  0.230024  
29 -0.060252 -0.286753  0.019128 -0.130230  0.082274  0.201970  
30 -0.188815  0.031972  0.001999  0.198570  0.050985 -0.034072  
31 -0.018440  0.079025 -0.067852 -0.284261  0.036103 -0.117081  
32  0.145882 -0.103288  0.203992 -0.116756  0.076426  0.234923  
33  0.168970 -0.002022  0.098905  0.036230 -0.081546 -0.010574  
34  0.033978  0.293218  0.264000 -0.136078 -0.114037 -0.014771  
35  0.105713 -0.205858  0.199661 -0.040368  0.215593  0.022981  
36  0.217448 -0.033608 -0.022585 -0.074371  0.015010  0.032643  
37  0.127809  0.361502 -0.083805 -0.253660  0.170848  0.036006  
38  0.002290  0.098220 -0.137063 -0.302110  0.025193  0.016161  
39  0.271195  0.044461  0.276102  0.132423 -0.090090  0.011019  
40 -0.046247  0.134117 -0.173648  0.139177  0.059323 -0.029598  
41 -0.017151  0.133301  0.298626  0.116004  0.100549 -0.082334  
42 -0.015377 -0.109279 -0.045829  0.117187 -0.025715  0.023530  
43  0.240223 -0.106473 -0.151702  0.022297 -0.020851  0.065501  
44 -0.470106  0.027777  0.114752  0.061756 -0.038943  0.044469  
45 -0.043603 -0.113039 -0.069130  0.230728 -0.039376 -0.033140  
46 -0.016175 -0.021679 -0.078828  0.129023  0.048788  0.000246  
47 -0.032990 -0.092084  0.140875 -0.058515 -0.003594  0.000128  
48 -0.054929 -0.076647 -0.091828 -0.085363  0.015527 -0.039280  
49 -0.119311  0.025686  0.140711 -0.069003 -0.045910  0.037151  
50 -0.022702 -0.061947 -0.262252  0.014536 -0.012179 -0.022354  
51 -0.332079  0.008076  0.040170  0.021009 -0.032186  0.029353  
52 -0.078423 -0.044029  0.015873  0.019973  0.003995  0.035962  
53 -0.042047 -0.058549  0.022550  0.138436  0.021769  0.016616  
54  0.016624 -0.103213 -0.184252  0.014723  0.063236  0.044584  
55  0.009089  0.077658 -0.130942  0.006535 -0.020046  0.000706  
56  0.216399  0.049881 -0.114774 -0.027399 -0.094796 -0.002292  
57 -0.039779 -0.057046  0.154184 -0.047830 -0.052748  0.047829  
58 -0.037651 -0.014551  0.149786 -0.054433  0.008412 -0.025205  
59  0.008155  0.009114  0.110148 -0.009105  0.026992  0.031712  

[60 rows x 60 columns]
Out[ ]:
AEFES AKBNK AKSA AKSEN ALARK ALBRK ANACM ARCLK ASELS ASUZU ... TTKOM TUKAS TUPRS USAK VAKBN VESTL YATAS YKBNK YUNSA ZOREN
count 60.000000 60.000000 60.000000 60.000000 60.000000 60.000000 60.000000 60.000000 60.000000 60.000000 ... 60.000000 60.000000 60.000000 60.000000 60.000000 60.000000 60.000000 60.000000 60.000000 60.000000
mean -0.017411 -0.013039 0.004856 0.016549 -0.005489 0.021732 0.003240 -0.004368 -0.002462 -0.001908 ... -0.015711 0.012170 -0.006585 -0.015528 -0.004759 -0.019486 0.010805 -0.013688 -0.001241 -0.000967
std 0.128999 0.129523 0.130097 0.129115 0.130071 0.128331 0.130148 0.130114 0.130165 0.130175 ... 0.129221 0.129609 0.130019 0.129244 0.130100 0.128697 0.129732 0.129455 0.130183 0.130185
min -0.490462 -0.246241 -0.358315 -0.195168 -0.398400 -0.238392 -0.280136 -0.368540 -0.325030 -0.368007 ... -0.314532 -0.319786 -0.524948 -0.328712 -0.470106 -0.328973 -0.262252 -0.302110 -0.389764 -0.362043
25% -0.070899 -0.088827 -0.081966 -0.081347 -0.087407 -0.024850 -0.081121 -0.078558 -0.064775 -0.079528 ... -0.089605 -0.070742 -0.067542 -0.125185 -0.056259 -0.097893 -0.085049 -0.092202 -0.057728 -0.049591
50% -0.019509 -0.028043 0.014903 -0.010485 -0.018563 0.006798 -0.014496 -0.016523 -0.003729 -0.004997 ... -0.020145 0.010962 0.004498 -0.005531 -0.013125 -0.009903 -0.003812 -0.017888 -0.007886 0.013590
75% 0.043943 0.072313 0.089969 0.092266 0.083342 0.059765 0.058544 0.062010 0.060761 0.057500 ... 0.047437 0.085223 0.070025 0.070012 0.069625 0.046437 0.111299 0.102857 0.057316 0.051491
max 0.398288 0.445732 0.291200 0.358492 0.266981 0.455893 0.384111 0.266634 0.510842 0.357246 ... 0.332803 0.318998 0.234714 0.231488 0.271195 0.361502 0.298626 0.252002 0.337128 0.252600

8 rows × 60 columns

In [ ]:
from sklearn.decomposition import PCA

pca = PCA(n_components=2)

principalComponents = pca.fit_transform(x)

principalDf = pd.DataFrame(data = principalComponents
             , columns = ['principal component 1', 'principal component 2'])

principalDf 
Out[ ]:
principal component 1 principal component 2
0 8.395567 0.870993
1 8.416420 0.953497
2 8.410296 0.949745
3 8.406200 0.940017
4 8.402837 0.911777
... ... ...
50007 -7.841826 2.672890
50008 -7.816749 2.723456
50009 -7.872200 2.710949
50010 -7.833913 2.719308
50011 -7.824803 2.714428

50012 rows × 2 columns

In [ ]:
explained_variance_ratio = pca.explained_variance_ratio_

# Print the explained variance ratios
print("Explained Variance Ratios:")
for i, ratio in enumerate(explained_variance_ratio):
    print(f"PC{i+1}: {ratio:.2f}")
Explained Variance Ratios:
PC1: 0.51
PC2: 0.17
In [ ]:
from sklearn.decomposition import PCA

pca = PCA(n_components=3)

principalComponents = pca.fit_transform(x)

principalDf = pd.DataFrame(data = principalComponents
             , columns = ['principal component 1', 'principal component 2', 'principal component 3'])

principalDf 
Out[ ]:
principal component 1 principal component 2 principal component 3
0 8.395567 0.870993 -0.689582
1 8.416420 0.953497 -0.675637
2 8.410296 0.949745 -0.679826
3 8.406200 0.940017 -0.664031
4 8.402837 0.911777 -0.691930
... ... ... ...
50007 -7.841826 2.672890 -0.547362
50008 -7.816749 2.723456 -0.548091
50009 -7.872200 2.710949 -0.532514
50010 -7.833913 2.719308 -0.507968
50011 -7.824803 2.714428 -0.508086

50012 rows × 3 columns

In [ ]:
explained_variance_ratio = pca.explained_variance_ratio_

# Print the explained variance ratios
print("Explained Variance Ratios:")
for i, ratio in enumerate(explained_variance_ratio):
    print(f"PC{i+1}: {ratio:.2f}")
Explained Variance Ratios:
PC1: 0.51
PC2: 0.17
PC3: 0.11
In [ ]:
print("Standard deviations:")
print(pca.explained_variance_)
print("Proportion of variance:")
print(pca.explained_variance_ratio_)
print("Cumulative proportion of variance:")
print(pca.explained_variance_ratio_.cumsum())

print("Loadings:")
print(pca.components_)
Standard deviations:
[30.49030684 10.33064651  6.42232574]
Proportion of variance:
[0.50816162 0.172174   0.10703662]
Cumulative proportion of variance:
[0.50816162 0.68033562 0.78737224]
Loadings:
[[-0.00797989 -0.10978214 -0.16024786 -0.06407439 -0.13601486 -0.00568723
  -0.16744146 -0.1219848  -0.17406645 -0.14868821 -0.16719171  0.07737154
  -0.16272716 -0.06192938  0.09492331 -0.11766653 -0.16685591 -0.17442011
  -0.17324891 -0.13112733 -0.10217255  0.02856573  0.10830698 -0.14620672
  -0.12042445 -0.14350589 -0.11668073 -0.15096929 -0.16926912 -0.1161842
  -0.16794952 -0.04518889 -0.1469359  -0.03664199 -0.12375029 -0.15469878
  -0.17518554 -0.05711586 -0.01416825 -0.05712187 -0.16617377 -0.16868442
   0.08926098 -0.15675589 -0.15538192 -0.14878012 -0.15117475 -0.1508164
  -0.17598265 -0.07712832  0.01481144 -0.1186344  -0.16744994 -0.12712093
  -0.09152314 -0.15593672 -0.17024646  0.04073147 -0.0901334  -0.12823051]
 [-0.16336015 -0.21592426 -0.03710458 -0.16163536 -0.08625967 -0.11361338
   0.05316789 -0.03772152 -0.00247925 -0.09387236 -0.03551955 -0.1300294
  -0.04932394 -0.06152575 -0.14837222 -0.05333797 -0.04310382  0.05520566
   0.06291216 -0.18088806 -0.06317509 -0.11195898 -0.21521401  0.04692607
  -0.19823917  0.11969054  0.15139875  0.10904285 -0.00182617 -0.10602862
   0.00682269 -0.0674117   0.01287499 -0.28509068 -0.0170458   0.0751868
   0.0030477  -0.03245286 -0.19218273 -0.26437786  0.08129119  0.08857294
  -0.18322757  0.13393748  0.00644959  0.05001733  0.12450551 -0.05137538
   0.01650922 -0.25742241 -0.2673212   0.06488638  0.09033229 -0.14646071
  -0.25242815  0.02992342 -0.02170823 -0.2765768  -0.00258073 -0.1014195 ]
 [-0.26622225  0.07366462  0.0720708  -0.1506053  -0.10550232 -0.2134519
  -0.08945294  0.25188258  0.00330487 -0.13093946  0.09497906  0.13403878
  -0.02498091  0.19929729 -0.13989354 -0.07683641  0.08004287 -0.0298757
  -0.03178404  0.01294246  0.17870569  0.25830419 -0.08283132 -0.07808297
   0.02321468 -0.15428514 -0.06003885  0.03558096 -0.07846125 -0.03480374
   0.11356639 -0.27965583 -0.14241383  0.03006372  0.24270922  0.01337871
   0.04251661 -0.25970513 -0.20422314  0.05284977 -0.09045705  0.02285603
  -0.13930962  0.04485308 -0.00492186 -0.16064703 -0.08783478  0.17616002
  -0.041297    0.08453179  0.10921686  0.07521602 -0.00824983  0.08280865
   0.02059318  0.0884369  -0.05468989 -0.05698797 -0.26130164  0.07135254]]

Certainly, here's a concise summary of PC1, PC2, and PC3 based on their explained variance ratios in a Principal Component Analysis (PCA):

PC1:

Explained Variance: 51% Dominant latent variable capturing the primary data pattern. PC2:

Explained Variance: 17% Captures additional, uncorrelated patterns. PC3:

Explained Variance: 11% Represents independent, less prominent patterns.

In [ ]:
from sklearn.decomposition import PCA

pca = PCA(n_components=9)

principalComponents = pca.fit_transform(x)

principalDf = pd.DataFrame(data = principalComponents
             , columns = ['principal component 1', 'principal component 2','principal component 3','principal component 4','principal component 5','principal component 6','principal component 7','principal component 8''principal component 9','principal component 10'])

principalDf 
explained_variance_ratio = pca.explained_variance_ratio_

# Print the explained variance ratios
print("Explained Variance Ratios:")
for i, ratio in enumerate(explained_variance_ratio):
    print(f"PC{i+1}: {ratio:.2f}")
Explained Variance Ratios:
PC1: 0.51
PC2: 0.17
PC3: 0.11
PC4: 0.05
PC5: 0.04
PC6: 0.02
PC7: 0.01
PC8: 0.01
PC9: 0.01
In [ ]:
import matplotlib.pyplot as plt

# Principal component labels (PC1 to PC9)
components = ['PC1', 'PC2', 'PC3', 'PC4', 'PC5', 'PC6', 'PC7', 'PC8', 'PC9']

# Explained variances for PC1 to PC9
explained_variances = [0.51, 0.17, 0.11, 0.05, 0.04, 0.02, 0.01, 0.01, 0.01]

# Create a bar plot
plt.bar(components, explained_variances, color='skyblue')
plt.xlabel('Principal Components')
plt.ylabel('Explained Variance')
plt.title('Explained Variance for Principal Components (PC1 to PC9)')
plt.show()
No description has been provided for this image
In [ ]:
correlation_matrix = Data_filled_timeless.corr()
np.fill_diagonal(correlation_matrix.values, 0)

# Display the correlation matrix
print(correlation_matrix)
          AEFES     AKBNK      AKSA     AKSEN     ALARK     ALBRK     ANACM  \
AEFES  0.000000  0.265172 -0.012122  0.521308  0.315361  0.503105  0.106100   
AKBNK  0.265172  0.000000  0.567416  0.531172  0.656149  0.160338  0.438333   
AKSA  -0.012122  0.567416  0.000000  0.219147  0.626336 -0.063763  0.707960   
AKSEN  0.521308  0.531172  0.219147  0.000000  0.446445  0.285215  0.438764   
ALARK  0.315361  0.656149  0.626336  0.446445  0.000000  0.158141  0.734758   
ALBRK  0.503105  0.160338 -0.063763  0.285215  0.158141  0.000000  0.068882   
ANACM  0.106100  0.438333  0.707960  0.438764  0.734758  0.068882  0.000000   
ARCLK -0.337666  0.643148  0.740921 -0.038953  0.461082 -0.253037  0.448305   
ASELS  0.035064  0.583076  0.844850  0.408688  0.747129 -0.063239  0.894125   
ASUZU  0.440741  0.584673  0.754438  0.566683  0.718186  0.318852  0.752457   
AYGAZ -0.051980  0.677050  0.899645  0.291432  0.696477 -0.104259  0.775535   
BAGFS  0.006692  0.033987 -0.274151  0.039251 -0.416179 -0.046661 -0.531851   
BANVT  0.153372  0.659102  0.772829  0.471309  0.861936 -0.056583  0.834471   
BRISA -0.229100  0.297074  0.486006 -0.176182 -0.054764  0.067195  0.060022   
CCOLA  0.481101 -0.081474 -0.410763 -0.078869 -0.124391  0.494149 -0.555986   
CEMAS  0.220141  0.459101  0.578476  0.659717  0.531732  0.001944  0.667902   
ECILC -0.040566  0.685352  0.893949  0.379831  0.722899 -0.139906  0.789561   
EREGL  0.015220  0.424460  0.831668  0.296478  0.653305 -0.022930  0.929395   
FROTO  0.005818  0.415052  0.818819  0.265335  0.650406  0.002325  0.925018   
GARAN  0.326121  0.936442  0.628744  0.498170  0.724072  0.258061  0.576693   
GOODY -0.152160  0.535968  0.570250  0.126226  0.282307 -0.042670  0.351869   
GUBRF -0.222250  0.132776  0.161095 -0.204825 -0.395999 -0.085913 -0.433420   
HALKB  0.437222  0.116712 -0.540029  0.251099 -0.155746  0.382223 -0.597118   
ICBCT  0.106240  0.328913  0.654832  0.293869  0.544015  0.036152  0.783822   
ISCTR  0.300368  0.909821  0.639640  0.497510  0.751942  0.204917  0.519111   
ISDMR  0.098281  0.150550  0.570717  0.273853  0.534514  0.144348  0.893909   
ISFIN -0.118504  0.083453  0.397492 -0.064247  0.411083  0.149047  0.736413   
ISYAT -0.201476  0.301473  0.728234 -0.113542  0.577324 -0.076428  0.780396   
KAREL  0.165144  0.563324  0.779169  0.439729  0.809521  0.119894  0.936724   
KARSN  0.269095  0.492122  0.669882  0.381247  0.384358  0.351149  0.504051   
KCHOL -0.149012  0.621032  0.839680  0.164146  0.653170 -0.063910  0.797950   
KRDMB  0.543139  0.061509  0.282523  0.226658  0.455579  0.477097  0.252868   
KRDMD  0.286676  0.329243  0.685679  0.448415  0.517678  0.202323  0.799012   
MGROS  0.412346  0.765185  0.281262  0.594540  0.399468  0.202422  0.032288   
OTKAR -0.369788  0.572501  0.745584 -0.076631  0.449921 -0.227990  0.479687   
PARSN -0.101860  0.365266  0.746728  0.271369  0.471572 -0.118050  0.825768   
PETKM -0.022398  0.618495  0.863999  0.339058  0.723767 -0.070263  0.884443   
PGSUS  0.455231  0.112036  0.248354  0.086575  0.558672  0.442826  0.344626   
PRKME  0.621465  0.426034 -0.024117  0.706689  0.482905  0.332525  0.144670   
SAHOL  0.420153  0.874562  0.359967  0.458704  0.491823  0.280905  0.137065   
SASA   0.058802  0.348357  0.718169  0.343454  0.652378  0.034038  0.963333   
SISE  -0.145425  0.389975  0.767653  0.136784  0.611452 -0.016399  0.908831   
SKBNK  0.530356 -0.040103 -0.349426  0.079131 -0.186915  0.545840 -0.563067   
SODA  -0.266101  0.253605  0.708470  0.029746  0.497584 -0.131516  0.857113   
TCELL  0.076181  0.451006  0.821456  0.031484  0.612873  0.158314  0.719892   
THYAO  0.236087  0.255787  0.673597  0.363101  0.549559  0.270220  0.850862   
TKFEN -0.024584  0.258495  0.555781  0.189139  0.633321  0.044481  0.928476   
TOASO -0.171724  0.670973  0.897573  0.206580  0.581100 -0.233571  0.622719   
TRKCM  0.082097  0.502678  0.854274  0.361278  0.726391  0.050399  0.923831   
TSKB   0.331086  0.855472  0.530657  0.574207  0.423720  0.177319  0.207461   
TTKOM  0.256178  0.577971  0.126886  0.207921  0.078597  0.235238 -0.308916   
TUKAS -0.225400  0.312425  0.579092 -0.109250  0.483431 -0.007662  0.594107   
TUPRS -0.106395  0.382141  0.732139  0.205825  0.652578 -0.029318  0.928222   
USAK   0.068725  0.784005  0.724250  0.560589  0.650606 -0.089070  0.558428   
VAKBN  0.396090  0.942750  0.503089  0.594608  0.651004  0.302873  0.344008   
VESTL -0.157526  0.481660  0.780727  0.090731  0.505632 -0.033687  0.740200   
YATAS  0.194608  0.597285  0.822706  0.424558  0.782436  0.051352  0.889055   
YKBNK  0.540599  0.516445 -0.178244  0.385192  0.158014  0.443267 -0.320544   
YUNSA  0.457522  0.084808  0.403309  0.374625  0.379516  0.454777  0.555568   
ZOREN  0.054961  0.625503  0.698531  0.337452  0.388649  0.176522  0.516512   

          ARCLK     ASELS     ASUZU  ...     TTKOM     TUKAS     TUPRS  \
AEFES -0.337666  0.035064  0.440741  ...  0.256178 -0.225400 -0.106395   
AKBNK  0.643148  0.583076  0.584673  ...  0.577971  0.312425  0.382141   
AKSA   0.740921  0.844850  0.754438  ...  0.126886  0.579092  0.732139   
AKSEN -0.038953  0.408688  0.566683  ...  0.207921 -0.109250  0.205825   
ALARK  0.461082  0.747129  0.718186  ...  0.078597  0.483431  0.652578   
ALBRK -0.253037 -0.063239  0.318852  ...  0.235238 -0.007662 -0.029318   
ANACM  0.448305  0.894125  0.752457  ... -0.308916  0.594107  0.928222   
ARCLK  0.000000  0.644469  0.325279  ...  0.235208  0.543088  0.571272   
ASELS  0.644469  0.000000  0.779530  ... -0.125700  0.536585  0.893284   
ASUZU  0.325279  0.779530  0.000000  ...  0.110716  0.384536  0.636442   
AYGAZ  0.835521  0.929536  0.688782  ...  0.044636  0.524998  0.814792   
BAGFS -0.146777 -0.410044 -0.309174  ...  0.453582 -0.256471 -0.513158   
BANVT  0.586699  0.936172  0.780917  ... -0.026286  0.499072  0.809699   
BRISA  0.492417  0.247454  0.284722  ...  0.375983  0.358573  0.205034   
CCOLA -0.396623 -0.562904 -0.192156  ...  0.407348 -0.467859 -0.634347   
CEMAS  0.292184  0.699250  0.659773  ... -0.065199  0.075078  0.506580   
ECILC  0.801955  0.940326  0.704750  ...  0.052609  0.498830  0.797005   
EREGL  0.564238  0.923790  0.773014  ... -0.256906  0.600595  0.929223   
FROTO  0.553140  0.907939  0.757108  ... -0.254112  0.651169  0.943424   
GARAN  0.585888  0.670255  0.720528  ...  0.444973  0.463186  0.534531   
GOODY  0.676808  0.558910  0.378788  ...  0.187098  0.287757  0.440353   
GUBRF  0.267541 -0.186179 -0.124541  ...  0.611728 -0.001442 -0.293304   
HALKB -0.429528 -0.566417 -0.274574  ...  0.531831 -0.547289 -0.698433   
ICBCT  0.370746  0.837018  0.677726  ... -0.296821  0.401830  0.811565   
ISCTR  0.601024  0.608979  0.664213  ...  0.514421  0.433461  0.461925   
ISDMR  0.207117  0.721796  0.663487  ... -0.473105  0.565494  0.864175   
ISFIN  0.316428  0.555274  0.380215  ... -0.455299  0.689811  0.801579   
ISYAT  0.632613  0.730029  0.538174  ... -0.275088  0.793710  0.873391   
KAREL  0.510225  0.895765  0.816987  ... -0.119497  0.661234  0.883856   
KARSN  0.276207  0.569759  0.813804  ...  0.286294  0.397713  0.455717   
KCHOL  0.831227  0.876829  0.633989  ... -0.015850  0.730062  0.886452   
KRDMB -0.167014  0.213080  0.540296  ...  0.053014 -0.046850  0.110626   
KRDMD  0.253266  0.758343  0.837855  ... -0.190449  0.333910  0.717417   
MGROS  0.276749  0.248521  0.389868  ...  0.739777 -0.094708 -0.061236   
OTKAR  0.919723  0.633919  0.371461  ...  0.190012  0.596799  0.589513   
PARSN  0.545087  0.830431  0.633380  ... -0.299878  0.478594  0.830680   
PETKM  0.732799  0.962750  0.742724  ... -0.091351  0.606537  0.891425   
PGSUS -0.144599  0.225062  0.509287  ... -0.021835  0.298204  0.261100   
PRKME -0.225790  0.165693  0.347944  ...  0.319377 -0.156251 -0.031074   
SAHOL  0.458573  0.276917  0.423083  ...  0.762486  0.086096  0.055916   
SASA   0.431820  0.878004  0.736117  ... -0.371578  0.596543  0.935729   
SISE   0.650024  0.879453  0.630035  ... -0.308587  0.709901  0.962126   
SKBNK -0.492411 -0.491880 -0.034939  ...  0.489633 -0.451638 -0.642820   
SODA   0.611731  0.816731  0.514626  ... -0.418108  0.707969  0.950503   
TCELL  0.593385  0.783634  0.738172  ... -0.016310  0.657050  0.780132   
THYAO  0.210616  0.767963  0.818661  ... -0.279923  0.479639  0.792847   
TKFEN  0.379961  0.779138  0.587129  ... -0.473376  0.688869  0.936478   
TOASO  0.895946  0.839020  0.598904  ...  0.186133  0.502404  0.685348   
TRKCM  0.587642  0.942208  0.823648  ... -0.166879  0.548554  0.891752   
TSKB   0.491454  0.426481  0.558325  ...  0.737732  0.085888  0.127556   
TTKOM  0.235208 -0.125700  0.110716  ...  0.000000 -0.054951 -0.340949   
TUKAS  0.543088  0.536585  0.384536  ... -0.054951  0.000000  0.737531   
TUPRS  0.571272  0.893284  0.636442  ... -0.340949  0.737531  0.000000   
USAK   0.649184  0.759339  0.613717  ...  0.335591  0.334332  0.535926   
VAKBN  0.521497  0.489618  0.596321  ...  0.647514  0.190639  0.251842   
VESTL  0.679081  0.751010  0.656484  ... -0.041763  0.724395  0.795190   
YATAS  0.542902  0.932127  0.846644  ... -0.047544  0.564226  0.844456   
YKBNK -0.122521 -0.260872  0.106371  ...  0.752921 -0.267913 -0.446585   
YUNSA -0.137644  0.425622  0.697668  ... -0.156237  0.138050  0.415343   
ZOREN  0.546037  0.637184  0.715896  ...  0.323633  0.388265  0.499454   

           USAK     VAKBN     VESTL     YATAS     YKBNK     YUNSA     ZOREN  
AEFES  0.068725  0.396090 -0.157526  0.194608  0.540599  0.457522  0.054961  
AKBNK  0.784005  0.942750  0.481660  0.597285  0.516445  0.084808  0.625503  
AKSA   0.724250  0.503089  0.780727  0.822706 -0.178244  0.403309  0.698531  
AKSEN  0.560589  0.594608  0.090731  0.424558  0.385192  0.374625  0.337452  
ALARK  0.650606  0.651004  0.505632  0.782436  0.158014  0.379516  0.388649  
ALBRK -0.089070  0.302873 -0.033687  0.051352  0.443267  0.454777  0.176522  
ANACM  0.558428  0.344008  0.740200  0.889055 -0.320544  0.555568  0.516512  
ARCLK  0.649184  0.521497  0.679081  0.542902 -0.122521 -0.137644  0.546037  
ASELS  0.759339  0.489618  0.751010  0.932127 -0.260872  0.425622  0.637184  
ASUZU  0.613717  0.596321  0.656484  0.846644  0.106371  0.697668  0.715896  
AYGAZ  0.807072  0.584630  0.763965  0.841454 -0.180368  0.269624  0.660128  
BAGFS -0.008295  0.072626 -0.273651 -0.404082  0.408554 -0.369039 -0.008490  
BANVT  0.797426  0.587242  0.670332  0.901837 -0.075558  0.366467  0.566885  
BRISA  0.263538  0.238441  0.544262  0.182941  0.017194  0.128996  0.667101  
CCOLA -0.350226  0.108308 -0.547587 -0.492072  0.617757  0.073131 -0.293610  
CEMAS  0.633222  0.432485  0.421761  0.662592 -0.052363  0.470942  0.476323  
ECILC  0.845233  0.599778  0.752808  0.858607 -0.160646  0.284822  0.662617  
EREGL  0.580790  0.320863  0.844860  0.894513 -0.366473  0.575305  0.622709  
FROTO  0.534652  0.296154  0.824209  0.888916 -0.374623  0.564103  0.614078  
GARAN  0.734838  0.888731  0.592027  0.717789  0.415514  0.278288  0.683128  
GOODY  0.552288  0.448244  0.594462  0.443432 -0.005511  0.032096  0.628992  
GUBRF  0.118210  0.123091  0.024583 -0.256328  0.183377 -0.274285  0.274241  
HALKB -0.094000  0.287207 -0.669084 -0.538088  0.796595 -0.188620 -0.321035  
ICBCT  0.511308  0.241439  0.580014  0.776574 -0.352774  0.553379  0.489382  
ISCTR  0.784523  0.915621  0.538133  0.647523  0.465811  0.254137  0.584164  
ISDMR  0.279140  0.063307  0.669293  0.757176 -0.426444  0.677550  0.393291  
ISFIN  0.105329 -0.001316  0.634780  0.593841 -0.485735  0.357839  0.269007  
ISYAT  0.329222  0.158897  0.811276  0.721688 -0.448969  0.355421  0.475290  
KAREL  0.654569  0.501534  0.773698  0.936903 -0.152536  0.522391  0.589410  
KARSN  0.490048  0.487213  0.617787  0.647264  0.124203  0.569324  0.781845  
KCHOL  0.660173  0.480493  0.868622  0.799409 -0.238772  0.247141  0.667008  
KRDMB  0.082963  0.220459  0.060000  0.332500  0.191926  0.708839  0.158768  
KRDMD  0.444986  0.296528  0.690673  0.791991 -0.179659  0.801137  0.630788  
MGROS  0.695834  0.839489  0.048836  0.237457  0.722927  0.046474  0.399510  
OTKAR  0.549266  0.443693  0.726979  0.549746 -0.178876 -0.062797  0.582825  
PARSN  0.515861  0.215951  0.749318  0.766841 -0.428126  0.442551  0.556136  
PETKM  0.726206  0.500513  0.811259  0.917050 -0.266180  0.346237  0.679104  
PGSUS  0.032829  0.172792  0.176820  0.365953  0.169164  0.603661  0.155074  
PRKME  0.412514  0.543268 -0.207194  0.250312  0.566828  0.197844  0.041971  
SAHOL  0.562702  0.896935  0.217775  0.320650  0.734075  0.047056  0.459516  
SASA   0.508513  0.249574  0.749880  0.870744 -0.405306  0.597570  0.509971  
SISE   0.502559  0.259367  0.843284  0.813822 -0.456254  0.424449  0.573767  
SKBNK -0.242786  0.158943 -0.512879 -0.377077  0.648642  0.072636 -0.102745  
SODA   0.426467  0.104101  0.805562  0.723136 -0.583118  0.369757  0.471818  
TCELL  0.453374  0.379217  0.757042  0.793327 -0.211518  0.520254  0.645894  
THYAO  0.365013  0.207472  0.646612  0.805468 -0.309348  0.773839  0.574430  
TKFEN  0.327262  0.127966  0.719675  0.774942 -0.450968  0.483484  0.384817  
TOASO  0.788273  0.568148  0.763305  0.751614 -0.139907  0.116256  0.685480  
TRKCM  0.635641  0.427903  0.815065  0.913053 -0.272866  0.602336  0.667245  
TSKB   0.728469  0.880002  0.340900  0.459221  0.573489  0.091424  0.664517  
TTKOM  0.335591  0.647514 -0.041763 -0.047544  0.752921 -0.156237  0.323633  
TUKAS  0.334332  0.190639  0.724395  0.564226 -0.267913  0.138050  0.388265  
TUPRS  0.535926  0.251842  0.795190  0.844456 -0.446585  0.415343  0.499454  
USAK   0.000000  0.752704  0.495247  0.675461  0.165511  0.137390  0.565870  
VAKBN  0.752704  0.000000  0.350838  0.531143  0.634297  0.141870  0.561643  
VESTL  0.495247  0.350838  0.000000  0.754297 -0.230744  0.358992  0.759059  
YATAS  0.675461  0.531143  0.754297  0.000000 -0.147035  0.502024  0.652366  
YKBNK  0.165511  0.634297 -0.230744 -0.147035  0.000000 -0.025209  0.106437  
YUNSA  0.137390  0.141870  0.358992  0.502024 -0.025209  0.000000  0.379015  
ZOREN  0.565870  0.561643  0.759059  0.652366  0.106437  0.379015  0.000000  

[60 rows x 60 columns]
In [ ]:
stacked_correlations = correlation_matrix.stack()

# Sort the pairs by correlation value in descending order
sorted_correlations = stacked_correlations.sort_values(ascending=False)

# Get the pair(s) with the highest correlation
highest_correlation_pairs = sorted_correlations.head(6)

# Display the pair(s) with the highest correlation
print("Pair(s) with the highest correlation:")
print(highest_correlation_pairs)
Pair(s) with the highest correlation:
TRKCM  EREGL    0.974073
EREGL  TRKCM    0.974073
FROTO  EREGL    0.972648
EREGL  FROTO    0.972648
AYGAZ  ECILC    0.971154
ECILC  AYGAZ    0.971154
dtype: float64
In [ ]:
plt.plot(Data_filled_timeless['TRKCM'], label='List 1')
plt.plot(Data_filled_timeless['EREGL'], label='List 2')
#a= StandardScaler().fit_transform(Data_filled_timeless['TRKCM'])
# Adding labels and legend
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Plot of Two Lists')
plt.legend()

# Display the plot
plt.show()
No description has been provided for this image
In [ ]:
plt.plot(Data_filled_timeless['AYGAZ'], label='List 1')
plt.plot(Data_filled_timeless['ECILC'], label='List 2')

# Adding labels and legend
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Plot of Two Lists')
plt.legend()

# Display the plot
plt.show()
No description has been provided for this image
In [ ]:
plt.plot(Data_filled_timeless['OTKAR'], label='List 1')
plt.plot(Data_filled_timeless['TUPRS'], label='List 2')

# Adding labels and legend
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Plot of Two Lists')
plt.legend()

# Display the plot
plt.show()
No description has been provided for this image

I choose these 3 pairs to analyze it 2 of them for their correlation rate and one of them that i liked it from the boxplot analysis

In [ ]:
# Create a DataFrame with a 'Month' column ranging from 1 to 87
DataPair1 = pd.DataFrame({'Month': list(range(1, 82))})
DataPair2 = pd.DataFrame({'Month': list(range(1, 82))})
DataPair3 = pd.DataFrame({'Month': list(range(1, 82))})


DataPair1['OTKAR'] = Data_timeless['OTKAR']  
DataPair1['TUPRS'] = Data_timeless['TUPRS']  

DataPair2['AYGAZ'] = Data_timeless['AYGAZ']  
DataPair2['ECILC'] = Data_timeless['ECILC']  

DataPair3['TRKCM'] = Data_timeless['TRKCM']  
DataPair3['EREGL'] = Data_timeless['EREGL']  

# Display the DataFrame
print(DataPair1)
output = pd.DataFrame(DataPair1)
output
    Month       OTKAR       TUPRS
0       1   25.196903   28.731524
1       2   25.656762   28.362370
2       3   25.318374   30.145567
3       4   25.770522   33.895264
4       5   27.400952   34.748862
..    ...         ...         ...
76     77   96.105671  112.551039
77     78  108.700879  127.260837
78     79  112.274200  131.386789
79     80  107.906259  129.464978
80     81  103.328378  120.396017

[81 rows x 3 columns]
Out[ ]:
Month OTKAR TUPRS
0 1 25.196903 28.731524
1 2 25.656762 28.362370
2 3 25.318374 30.145567
3 4 25.770522 33.895264
4 5 27.400952 34.748862
... ... ... ...
76 77 96.105671 112.551039
77 78 108.700879 127.260837
78 79 112.274200 131.386789
79 80 107.906259 129.464978
80 81 103.328378 120.396017

81 rows × 3 columns

In [ ]:
output2 = pd.DataFrame(DataPair2)
print(output2)

output3 = pd.DataFrame(DataPair3)
print(output3)

list_corr1 = []
list_corr2 = []
list_corr3 = []
    Month      AYGAZ     ECILC
0       1   3.454684  0.810134
1       2   3.440262  0.788359
2       3   3.692111  0.782510
3       4   4.045729  0.824110
4       5   4.391287  0.886488
..    ...        ...       ...
76     77  10.378431  2.494400
77     78  10.157537  2.702138
78     79  10.057255  2.654632
79     80   9.484292  2.473291
80     81   8.746060  2.313946

[81 rows x 3 columns]
    Month     TRKCM     EREGL
0       1  0.429993  0.786624
1       2  0.417833  0.755184
2       3  0.440100  0.758716
3       4  0.464104  0.840054
4       5  0.565576  0.896085
..    ...       ...       ...
76     77  3.028934  6.610235
77     78  3.482505  7.370253
78     79  3.568281  7.687748
79     80  3.124604  7.802562
80     81  2.828925  7.417945

[81 rows x 3 columns]
In [ ]:
output['OTKAR'].rolling(6).corr(output['TUPRS'])
 
# formatting the output
k = 1
for i, j in enumerate(output['OTKAR'].rolling(6).corr(output['TUPRS'])):
    if (i >= 5 and i < 82):
        print(f'The correlation in stocks during months\
        {k} through {i+1} is {j}')
        list_corr1.append(round(j,2))
        i = 0
        k += 1
The correlation in stocks during months        1 through 6 is 0.7883928312390968
The correlation in stocks during months        2 through 7 is 0.7165450123326561
The correlation in stocks during months        3 through 8 is 0.3147359150633959
The correlation in stocks during months        4 through 9 is 0.17920008545138466
The correlation in stocks during months        5 through 10 is -0.4765864350639622
The correlation in stocks during months        6 through 11 is -0.4874653402396
The correlation in stocks during months        7 through 12 is -0.4010560326076644
The correlation in stocks during months        8 through 13 is 0.19613465512679554
The correlation in stocks during months        9 through 14 is 0.8577770541272218
The correlation in stocks during months        10 through 15 is 0.897679056857705
The correlation in stocks during months        11 through 16 is 0.6470827243098127
The correlation in stocks during months        12 through 17 is 0.8792959699052186
The correlation in stocks during months        13 through 18 is 0.9391989890319423
The correlation in stocks during months        14 through 19 is 0.8775706135960225
The correlation in stocks during months        15 through 20 is 0.5726803598869044
The correlation in stocks during months        16 through 21 is 0.5052478737531151
The correlation in stocks during months        17 through 22 is 0.9315006421220431
The correlation in stocks during months        18 through 23 is 0.9905932451337914
The correlation in stocks during months        19 through 24 is 0.9814350020540931
The correlation in stocks during months        20 through 25 is 0.7961189586849352
The correlation in stocks during months        21 through 26 is -0.6564870128758725
The correlation in stocks during months        22 through 27 is -0.4488511199053289
The correlation in stocks during months        23 through 28 is 0.45300775988262304
The correlation in stocks during months        24 through 29 is 0.8334805228285507
The correlation in stocks during months        25 through 30 is 0.9043764816849587
The correlation in stocks during months        26 through 31 is 0.9258520705087581
The correlation in stocks during months        27 through 32 is 0.7999678358604003
The correlation in stocks during months        28 through 33 is 0.5990352660409132
The correlation in stocks during months        29 through 34 is -0.1555726240012433
The correlation in stocks during months        30 through 35 is -0.3647114214536127
The correlation in stocks during months        31 through 36 is -0.6630856726562067
The correlation in stocks during months        32 through 37 is -0.9385767630101385
The correlation in stocks during months        33 through 38 is -0.8072816755329058
The correlation in stocks during months        34 through 39 is -0.48782326988127817
The correlation in stocks during months        35 through 40 is -0.2527393687185909
The correlation in stocks during months        36 through 41 is -0.049896241863486776
The correlation in stocks during months        37 through 42 is -0.35841180629266506
The correlation in stocks during months        38 through 43 is 0.05059179569227542
The correlation in stocks during months        39 through 44 is 0.7433299124924181
The correlation in stocks during months        40 through 45 is 0.9186031742436659
The correlation in stocks during months        41 through 46 is 0.697895065945761
The correlation in stocks during months        42 through 47 is 0.48161774502290844
The correlation in stocks during months        43 through 48 is 0.2876363337947782
The correlation in stocks during months        44 through 49 is 0.19595159158857126
The correlation in stocks during months        45 through 50 is -0.9316549638320035
The correlation in stocks during months        46 through 51 is 0.2129789866568973
The correlation in stocks during months        47 through 52 is 0.8634627421344687
The correlation in stocks during months        48 through 53 is 0.9767789167126626
The correlation in stocks during months        49 through 54 is 0.9665812900831784
The correlation in stocks during months        50 through 55 is 0.8117064839344403
The correlation in stocks during months        51 through 56 is 0.5482650353178739
The correlation in stocks during months        52 through 57 is 0.23961668017496876
The correlation in stocks during months        53 through 58 is -0.6330862023871466
The correlation in stocks during months        54 through 59 is -0.674632565674954
The correlation in stocks during months        55 through 60 is -0.6204113581522965
The correlation in stocks during months        56 through 61 is -0.7996274084342989
The correlation in stocks during months        57 through 62 is -0.8991215948797153
The correlation in stocks during months        58 through 63 is -0.5751057043285953
The correlation in stocks during months        59 through 64 is -0.5942282982850526
The correlation in stocks during months        60 through 65 is -0.47239496838801337
The correlation in stocks during months        61 through 66 is -0.5186991773608818
The correlation in stocks during months        62 through 67 is -0.5934851927239764
The correlation in stocks during months        63 through 68 is -0.359838479748605
The correlation in stocks during months        64 through 69 is 0.11126004163289537
The correlation in stocks during months        65 through 70 is -0.31983989161815624
The correlation in stocks during months        66 through 71 is -0.2705612337394221
The correlation in stocks during months        67 through 72 is -0.23899518686556664
The correlation in stocks during months        68 through 73 is -0.15732931325405244
The correlation in stocks during months        69 through 74 is 0.2755588913711922
The correlation in stocks during months        70 through 75 is 0.5690782357211369
The correlation in stocks during months        71 through 76 is 0.38518048106333386
The correlation in stocks during months        72 through 77 is 0.19105100562017588
The correlation in stocks during months        73 through 78 is 0.48476346509145785
The correlation in stocks during months        74 through 79 is 0.7287865889376727
The correlation in stocks during months        75 through 80 is 0.92481931417226
The correlation in stocks during months        76 through 81 is 0.9488076742666673
In [ ]:
output2['AYGAZ'].rolling(3).corr(output2['ECILC'])
 
# formatting the output
k = 1
for i, j in enumerate(output2['AYGAZ'].rolling(3).corr(output2['ECILC'])):
    if (i >=2 and i < 82):
        print(f'The correlation in stocks during months\
        {k} through {i+1} is {j}')
        list_corr2.append(round(j,2))
        i = 0
        k += 1
The correlation in stocks during months        1 through 3 is -0.6247924019064495
The correlation in stocks during months        2 through 4 is 0.8487970518193222
The correlation in stocks during months        3 through 5 is 0.9926255884117215
The correlation in stocks during months        4 through 6 is 0.6354404943528326
The correlation in stocks during months        5 through 7 is 0.6642472411033291
The correlation in stocks during months        6 through 8 is 0.9679230543069464
The correlation in stocks during months        7 through 9 is 0.8783443602937578
The correlation in stocks during months        8 through 10 is 0.1338504988036819
The correlation in stocks during months        9 through 11 is 0.6653633614091338
The correlation in stocks during months        10 through 12 is -0.7166750456711233
The correlation in stocks during months        11 through 13 is -0.9991454088387202
The correlation in stocks during months        12 through 14 is 0.5665858181940739
The correlation in stocks during months        13 through 15 is 0.9907940370161482
The correlation in stocks during months        14 through 16 is 0.9494656674540457
The correlation in stocks during months        15 through 17 is 0.9997507202573741
The correlation in stocks during months        16 through 18 is 0.7239193464004651
The correlation in stocks during months        17 through 19 is -0.9905956966758789
The correlation in stocks during months        18 through 20 is 0.8501861280072003
The correlation in stocks during months        19 through 21 is 0.8867740992917723
The correlation in stocks during months        20 through 22 is 0.9153146302210713
The correlation in stocks during months        21 through 23 is 0.35519574068932125
The correlation in stocks during months        22 through 24 is -0.9991014844026582
The correlation in stocks during months        23 through 25 is -0.985187736324145
The correlation in stocks during months        24 through 26 is -0.9991311474177981
The correlation in stocks during months        25 through 27 is 0.7471354905485799
The correlation in stocks during months        26 through 28 is 0.9895917117419468
The correlation in stocks during months        27 through 29 is 0.9745630914161906
The correlation in stocks during months        28 through 30 is 0.7218359412277003
The correlation in stocks during months        29 through 31 is 0.9372703673743512
The correlation in stocks during months        30 through 32 is 0.9548347282574001
The correlation in stocks during months        31 through 33 is 0.9741115017947843
The correlation in stocks during months        32 through 34 is 0.7124607301021518
The correlation in stocks during months        33 through 35 is -0.8124095241331774
The correlation in stocks during months        34 through 36 is 0.20387223565897666
The correlation in stocks during months        35 through 37 is 0.9054678044443778
The correlation in stocks during months        36 through 38 is 0.887448324279588
The correlation in stocks during months        37 through 39 is 0.9999769436689041
The correlation in stocks during months        38 through 40 is 0.8559255808091821
The correlation in stocks during months        39 through 41 is -0.15381002177047878
The correlation in stocks during months        40 through 42 is 0.6044147218090721
The correlation in stocks during months        41 through 43 is 0.9557465097169345
The correlation in stocks during months        42 through 44 is 0.977317116585786
The correlation in stocks during months        43 through 45 is 0.9598474641476087
The correlation in stocks during months        44 through 46 is 0.40856533836711467
The correlation in stocks during months        45 through 47 is 0.6134448266424374
The correlation in stocks during months        46 through 48 is 0.9532460695958852
The correlation in stocks during months        47 through 49 is -0.8534252385154951
The correlation in stocks during months        48 through 50 is -0.6053175902694018
The correlation in stocks during months        49 through 51 is 0.9937120418622475
The correlation in stocks during months        50 through 52 is -0.6773168261470577
The correlation in stocks during months        51 through 53 is 0.8745111033982509
The correlation in stocks during months        52 through 54 is 0.9911583939677056
The correlation in stocks during months        53 through 55 is 0.934333400486254
The correlation in stocks during months        54 through 56 is 0.905245669835003
The correlation in stocks during months        55 through 57 is 0.9999564974468999
The correlation in stocks during months        56 through 58 is 0.9590778162909225
The correlation in stocks during months        57 through 59 is 0.9108240095787367
The correlation in stocks during months        58 through 60 is -0.42211067584003126
The correlation in stocks during months        59 through 61 is 0.8330964349184018
The correlation in stocks during months        60 through 62 is 0.8987306751891881
The correlation in stocks during months        61 through 63 is -0.1662726032034934
The correlation in stocks during months        62 through 64 is 0.5539975817435749
The correlation in stocks during months        63 through 65 is 0.861301202841466
The correlation in stocks during months        64 through 66 is 0.9723974040830231
The correlation in stocks during months        65 through 67 is 0.960290576247184
The correlation in stocks during months        66 through 68 is -0.8609250925289245
The correlation in stocks during months        67 through 69 is 0.9906339388604045
The correlation in stocks during months        68 through 70 is 0.9743729411999114
The correlation in stocks during months        69 through 71 is 0.9166223972591643
The correlation in stocks during months        70 through 72 is 0.3919491836641618
The correlation in stocks during months        71 through 73 is 0.9199855833120772
The correlation in stocks during months        72 through 74 is -0.33731393270997423
The correlation in stocks during months        73 through 75 is 0.7114367806342057
The correlation in stocks during months        74 through 76 is 0.997432861201181
The correlation in stocks during months        75 through 77 is 0.20551719844902983
The correlation in stocks during months        76 through 78 is -0.6592066402463481
The correlation in stocks during months        77 through 79 is -0.8627657766020904
The correlation in stocks during months        78 through 80 is 0.9982314389785114
The correlation in stocks during months        79 through 81 is 0.9939667794607046
In [ ]:
output3['TRKCM'].rolling(3).corr(output3['EREGL'])
 
# formatting the output
k = 1
for i, j in enumerate(output3['TRKCM'].rolling(3).corr(output3['EREGL'])):
    if (i >= 2 and i < 82):
        print(f'The correlation in stocks during months\
        {k} through {i+1} is {j}')
        list_corr3.append(round(j,2))
        i = 0
        k += 1
The correlation in stocks during months        1 through 3 is 0.1552909426729977
The correlation in stocks during months        2 through 4 is 0.8937595275974255
The correlation in stocks during months        3 through 5 is 0.9011544792478664
The correlation in stocks during months        4 through 6 is 0.6384148794819002
The correlation in stocks during months        5 through 7 is 0.6858388606406023
The correlation in stocks during months        6 through 8 is -0.0664047267957055
The correlation in stocks during months        7 through 9 is 0.9996916014794439
The correlation in stocks during months        8 through 10 is 0.9889142971376731
The correlation in stocks during months        9 through 11 is 0.5049618124526561
The correlation in stocks during months        10 through 12 is -0.4365335698765683
The correlation in stocks during months        11 through 13 is -0.9665081732869942
The correlation in stocks during months        12 through 14 is -0.21276165694812274
The correlation in stocks during months        13 through 15 is 0.9464272626676075
The correlation in stocks during months        14 through 16 is 0.13902439607023864
The correlation in stocks during months        15 through 17 is -0.6817157668639549
The correlation in stocks during months        16 through 18 is -0.48278246546478404
The correlation in stocks during months        17 through 19 is 0.9931532820078057
The correlation in stocks during months        18 through 20 is 0.9678075776250548
The correlation in stocks during months        19 through 21 is 0.9898717297406795
The correlation in stocks during months        20 through 22 is 0.9612926195168585
The correlation in stocks during months        21 through 23 is 0.9916863593244125
The correlation in stocks during months        22 through 24 is 0.999742385453099
The correlation in stocks during months        23 through 25 is -0.9223145890880804
The correlation in stocks during months        24 through 26 is -0.037488717282529754
The correlation in stocks during months        25 through 27 is 0.8966121026418151
The correlation in stocks during months        26 through 28 is 0.47335443683622125
The correlation in stocks during months        27 through 29 is 0.6743730100302326
The correlation in stocks during months        28 through 30 is -0.0410941751552051
The correlation in stocks during months        29 through 31 is 0.759014095887258
The correlation in stocks during months        30 through 32 is 0.4252740096579751
The correlation in stocks during months        31 through 33 is 0.9510919467600029
The correlation in stocks during months        32 through 34 is -0.5062955557001445
The correlation in stocks during months        33 through 35 is 0.7521172857527338
The correlation in stocks during months        34 through 36 is 0.9955578380750912
The correlation in stocks during months        35 through 37 is 0.9941841562866262
The correlation in stocks during months        36 through 38 is 0.9572339481043544
The correlation in stocks during months        37 through 39 is 0.9339878869705567
The correlation in stocks during months        38 through 40 is 0.9989035074649002
The correlation in stocks during months        39 through 41 is 0.9802034333390601
The correlation in stocks during months        40 through 42 is 0.9281499749837885
The correlation in stocks during months        41 through 43 is 0.9982354324972812
The correlation in stocks during months        42 through 44 is 0.9984252473528794
The correlation in stocks during months        43 through 45 is 0.9225147616507794
The correlation in stocks during months        44 through 46 is -0.9628562409183636
The correlation in stocks during months        45 through 47 is 0.8124577064772022
The correlation in stocks during months        46 through 48 is 0.9971294393737137
The correlation in stocks during months        47 through 49 is 0.6248325673468231
The correlation in stocks during months        48 through 50 is 0.16809785830512736
The correlation in stocks during months        49 through 51 is -0.8526747020048057
The correlation in stocks during months        50 through 52 is 0.9890645191383636
The correlation in stocks during months        51 through 53 is 0.9988643845653128
The correlation in stocks during months        52 through 54 is 0.9999768332072027
The correlation in stocks during months        53 through 55 is 0.9825620721615638
The correlation in stocks during months        54 through 56 is 0.9260469611969653
The correlation in stocks during months        55 through 57 is 0.9822385683378518
The correlation in stocks during months        56 through 58 is 0.9406243077241488
The correlation in stocks during months        57 through 59 is 0.9514711840925445
The correlation in stocks during months        58 through 60 is 0.9924878764574232
The correlation in stocks during months        59 through 61 is 0.5014234406775986
The correlation in stocks during months        60 through 62 is 0.9999042700167743
The correlation in stocks during months        61 through 63 is 0.9760796065209538
The correlation in stocks during months        62 through 64 is 0.9854938494042039
The correlation in stocks during months        63 through 65 is 0.9884052859929707
The correlation in stocks during months        64 through 66 is 0.9330901527024322
The correlation in stocks during months        65 through 67 is 0.6418322690141343
The correlation in stocks during months        66 through 68 is 0.8836151181268307
The correlation in stocks during months        67 through 69 is -0.9992289416796162
The correlation in stocks during months        68 through 70 is -0.9981223457508694
The correlation in stocks during months        69 through 71 is 0.7541074809730113
The correlation in stocks during months        70 through 72 is 0.7979833189888588
The correlation in stocks during months        71 through 73 is 0.6664608259733191
The correlation in stocks during months        72 through 74 is 0.8676481383283822
The correlation in stocks during months        73 through 75 is 0.9894107044141528
The correlation in stocks during months        74 through 76 is 0.9729893102570754
The correlation in stocks during months        75 through 77 is 0.6032840080025191
The correlation in stocks during months        76 through 78 is 0.9998194621531629
The correlation in stocks during months        77 through 79 is 0.9898980085817916
The correlation in stocks during months        78 through 80 is -0.5643007991728114
The correlation in stocks during months        79 through 81 is 0.5948888827190905
In [ ]:
print(list_corr1)
print(list_corr2)
print(list_corr3)
[0.79, 0.72, 0.31, 0.18, -0.48, -0.49, -0.4, 0.2, 0.86, 0.9, 0.65, 0.88, 0.94, 0.88, 0.57, 0.51, 0.93, 0.99, 0.98, 0.8, -0.66, -0.45, 0.45, 0.83, 0.9, 0.93, 0.8, 0.6, -0.16, -0.36, -0.66, -0.94, -0.81, -0.49, -0.25, -0.05, -0.36, 0.05, 0.74, 0.92, 0.7, 0.48, 0.29, 0.2, -0.93, 0.21, 0.86, 0.98, 0.97, 0.81, 0.55, 0.24, -0.63, -0.67, -0.62, -0.8, -0.9, -0.58, -0.59, -0.47, -0.52, -0.59, -0.36, 0.11, -0.32, -0.27, -0.24, -0.16, 0.28, 0.57, 0.39, 0.19, 0.48, 0.73, 0.92, 0.95]
[-0.62, 0.85, 0.99, 0.64, 0.66, 0.97, 0.88, 0.13, 0.67, -0.72, -1.0, 0.57, 0.99, 0.95, 1.0, 0.72, -0.99, 0.85, 0.89, 0.92, 0.36, -1.0, -0.99, -1.0, 0.75, 0.99, 0.97, 0.72, 0.94, 0.95, 0.97, 0.71, -0.81, 0.2, 0.91, 0.89, 1.0, 0.86, -0.15, 0.6, 0.96, 0.98, 0.96, 0.41, 0.61, 0.95, -0.85, -0.61, 0.99, -0.68, 0.87, 0.99, 0.93, 0.91, 1.0, 0.96, 0.91, -0.42, 0.83, 0.9, -0.17, 0.55, 0.86, 0.97, 0.96, -0.86, 0.99, 0.97, 0.92, 0.39, 0.92, -0.34, 0.71, 1.0, 0.21, -0.66, -0.86, 1.0, 0.99]
[0.16, 0.89, 0.9, 0.64, 0.69, -0.07, 1.0, 0.99, 0.5, -0.44, -0.97, -0.21, 0.95, 0.14, -0.68, -0.48, 0.99, 0.97, 0.99, 0.96, 0.99, 1.0, -0.92, -0.04, 0.9, 0.47, 0.67, -0.04, 0.76, 0.43, 0.95, -0.51, 0.75, 1.0, 0.99, 0.96, 0.93, 1.0, 0.98, 0.93, 1.0, 1.0, 0.92, -0.96, 0.81, 1.0, 0.62, 0.17, -0.85, 0.99, 1.0, 1.0, 0.98, 0.93, 0.98, 0.94, 0.95, 0.99, 0.5, 1.0, 0.98, 0.99, 0.99, 0.93, 0.64, 0.88, -1.0, -1.0, 0.75, 0.8, 0.67, 0.87, 0.99, 0.97, 0.6, 1.0, 0.99, -0.56, 0.59]
In [ ]:
import seaborn as sns

correlation_values = list_corr1

# Create a list of time period labels
time_periods =  list(range(1, 77))

# Create a data frame for the correlations
correlation_data = pd.DataFrame({'Time Period': time_periods, 'Correlation': list_corr1})

# Create a heatmap using seaborn
plt.figure(figsize=(30, 20))
sns.heatmap(data=correlation_data.pivot_table(index='Time Period', columns='Time Period', values='Correlation'),
            annot=True, fmt=".3f", cmap="coolwarm", xticklabels=True, yticklabels=True)
plt.title('Correlations in OTKAR TUPRAS Over Different Time Periods')
plt.show()
No description has been provided for this image
In [ ]:
import seaborn as sns

correlation_values = list_corr2

# Create a list of time period labels
time_periods =  list(range(1, 80))

# Create a data frame for the correlations
correlation_data = pd.DataFrame({'Time Period': time_periods, 'Correlation': list_corr2})

# Create a heatmap using seaborn
plt.figure(figsize=(30, 20))
sns.heatmap(data=correlation_data.pivot_table(index='Time Period', columns='Time Period', values='Correlation'),
            annot=True, fmt=".3f", cmap="coolwarm", xticklabels=True, yticklabels=True)
plt.title('Correlations in AYGAZ ECILC Over Different Time Periods')
plt.show()
No description has been provided for this image
In [ ]:
import seaborn as sns

correlation_values = list_corr3

# Create a list of time period labels
time_periods =  list(range(1, 80))

# Create a data frame for the correlations
correlation_data = pd.DataFrame({'Time Period': time_periods, 'Correlation': list_corr3})

# Create a heatmap using seaborn
plt.figure(figsize=(30, 20))
sns.heatmap(data=correlation_data.pivot_table(index='Time Period', columns='Time Period', values='Correlation'),
            annot=True, fmt=".3f", cmap="coolwarm", xticklabels=True, yticklabels=True)
plt.title('Correlations in TRKCM EREGL Over Different Time Periods')
plt.show()
No description has been provided for this image

As we can see in the graph in 3 month window correlation last 2 stock pairs does look like correlated. But the first one even in 6 months window correlation is not correlated.

TRKCM AND EREGL even though they are not ın same ındustry they have a tendency to grow together

aygaz and ecılc are also have a sımılıar tendencyç

However otkar and tuprs have a seasonal varıabılıty sometımes correlated ın a posıtıve way sometımes correlated ın a negatıve way

In [ ]:
Google_tupras = pd.read_csv (r'C:\Users\erdil/Desktop/DataMining/tupras.csv')
print(Google_tupras)
point = Google_tupras['Tupras'].tolist()
         Ay  Tupras
0   2012-09      39
1   2012-10      32
2   2012-11      32
3   2012-12      29
4   2013-01      29
..      ...     ...
73  2018-10      69
74  2018-11      63
75  2018-12      43
76  2019-01      45
77  2019-02      65

[78 rows x 2 columns]
In [ ]:
my_list = Data_timeless['TUPRS']  
Tupras_monthly= my_list[:-5]
Tupras_monthly.head(79)
Out[ ]:
0      28.731524
1      28.362370
2      30.145567
3      33.895264
4      34.748862
         ...    
73    120.739631
74    111.781556
75    108.765277
76    112.551039
77    127.260837
Name: TUPRS, Length: 78, dtype: float64
In [ ]:
correlation = np.corrcoef(point, Tupras_monthly)[0, 1]

# Print the correlation coefficient
print("Correlation coefficient:", correlation)
Correlation coefficient: 0.6482784191509634
In [ ]:
plt.plot(point, label='List 1')
plt.plot(Tupras_monthly, label='List 2')

# Adding labels and legend
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Plot of Two Lists')
plt.legend()

# Display the plot
plt.show()
No description has been provided for this image
In [ ]:
from sklearn.preprocessing import StandardScaler
mean = np.mean(point)
std_dev = np.std(point)

# Standardize the list
standardized_data = [(x - mean) / std_dev for x in point]

print("Original Data:", point)
print("Standardized Data:", standardized_data)
Original Data: [39, 32, 32, 29, 29, 57, 40, 44, 37, 31, 62, 51, 38, 31, 28, 29, 34, 28, 36, 30, 28, 29, 31, 25, 28, 28, 50, 63, 37, 37, 37, 36, 30, 34, 38, 44, 41, 30, 35, 31, 31, 56, 38, 41, 34, 37, 38, 44, 35, 37, 28, 28, 29, 49, 53, 37, 36, 38, 36, 44, 34, 100, 64, 56, 49, 60, 61, 55, 62, 46, 55, 78, 69, 69, 63, 43, 45, 65]
Standardized Data: [-0.22835059487528367, -0.7270682940829033, -0.7270682940829033, -0.9408044508861689, -0.9408044508861689, 1.0540663459443098, -0.15710520927419516, 0.12787633313015895, -0.3708413660774607, -0.7983136796839918, 1.4102932739497522, 0.6265940323377786, -0.2995959804763722, -0.7983136796839918, -1.0120498364872574, -0.9408044508861689, -0.5845775228807263, -1.0120498364872574, -0.4420867516785492, -0.8695590652850804, -1.0120498364872574, -0.9408044508861689, -0.7983136796839918, -1.225785993290523, -1.0120498364872574, -1.0120498364872574, 0.55534864673669, 1.4815386595508409, -0.3708413660774607, -0.3708413660774607, -0.3708413660774607, -0.4420867516785492, -0.8695590652850804, -0.5845775228807263, -0.2995959804763722, 0.12787633313015895, -0.08585982367310663, -0.8695590652850804, -0.5133321372796378, -0.7983136796839918, -0.7983136796839918, 0.9828209603432212, -0.2995959804763722, -0.08585982367310663, -0.5845775228807263, -0.3708413660774607, -0.2995959804763722, 0.12787633313015895, -0.5133321372796378, -0.3708413660774607, -1.0120498364872574, -1.0120498364872574, -0.9408044508861689, 0.48410326113560154, 0.7690848035399557, -0.3708413660774607, -0.4420867516785492, -0.2995959804763722, -0.4420867516785492, 0.12787633313015895, -0.5845775228807263, 4.117617926791116, 1.5527840451519295, 0.9828209603432212, 0.48410326113560154, 1.2678025027475752, 1.3390478883486638, 0.9115755747421327, 1.4102932739497522, 0.27036710433233596, 0.9115755747421327, 2.5502194435671686, 1.909010973157372, 1.909010973157372, 1.4815386595508409, 0.05663094752907041, 0.19912171873124745, 1.6240294307530179]
In [ ]:
from sklearn.preprocessing import StandardScaler
mean = np.mean(Tupras_monthly)
std_dev = np.std(Tupras_monthly)

# Standardize the list
standardized_data2 = [(x - mean) / std_dev for x in Tupras_monthly]

print("Original Data:", Tupras_monthly)
print("Standardized Data:", standardized_data2)
Original Data: 0      28.731524
1      28.362370
2      30.145567
3      33.895264
4      34.748862
         ...    
73    120.739631
74    111.781556
75    108.765277
76    112.551039
77    127.260837
Name: TUPRS, Length: 78, dtype: float64
Standardized Data: [-0.9810877619858778, -0.9939574817924203, -0.9317903237080088, -0.8010655871985596, -0.7713067889682206, -0.8115824007927293, -0.7235502594758607, -0.7980915650445255, -0.7666474471743273, -0.9200272160005454, -0.9470068589297677, -0.9887761791362074, -0.9829855382212704, -0.94294063525415, -0.9398366400675167, -0.9381574128091521, -1.0257569656489671, -1.0500746515129193, -0.9839035114103037, -0.8867449797582589, -0.8330709716050739, -0.7770771526778124, -0.7825659931676247, -0.7880525366198537, -0.8213739330451089, -0.9001979225120124, -0.8097290279829, -0.7489695427365224, -0.6764472943312632, -0.7098281747531779, -0.6851146211237416, -0.5118332496575076, -0.44971618982200423, -0.4350074879669723, -0.33399795677822314, -0.2740272430378818, -0.27302193311098516, -0.18726113445080497, -0.19506026391591005, -0.29195610005563283, -0.24378646074415306, -0.273617622860055, -0.15026325824181141, -0.07833072129459302, -0.2522005545533431, -0.3419701200800962, -0.3551354015778867, -0.44083695816619534, -0.49926284352075523, -0.42208126401772905, -0.3053521256533427, -0.17018184544846748, -0.05058332173510784, 0.1911664481263599, 0.300966731993504, 0.3750741325584217, 0.6036377195347973, 0.7501175563408639, 0.9182401158832605, 1.1957443296882995, 1.370795471753283, 1.5566915075036796, 1.5837160033253224, 1.304174656422991, 1.3094085437298546, 1.16549223190505, 1.2859616159192624, 1.442940355999981, 1.197806035449306, 1.4525478709703694, 1.278473795317726, 1.5749753299841607, 2.0503230862797057, 2.226567903316353, 1.9142647987936612, 1.8091090142374384, 1.9410910945236692, 2.45391508257682]
In [ ]:
plt.plot(standardized_data, label='search')
plt.plot(standardized_data2, label='stock')

# Adding labels and legend
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Plot tupras monthly stock prices and search points of Two Lists')
plt.legend()

# Display the plot
plt.show()
No description has been provided for this image

we can see that in the search area, the change on the stock market looks like affected the searching on google about the company

In [ ]:
dogalgaz = pd.read_csv (r'C:\Users\erdil/Desktop/DataMining/dogalgaz.csv')
print(dogalgaz)
point2 = dogalgaz['dogalgaz'].tolist()
point2
         Ay  dogalgaz
0   2012-09        48
1   2012-10        39
2   2012-11        48
3   2012-12        48
4   2013-01        50
..      ...       ...
73  2018-10        82
74  2018-11        92
75  2018-12        97
76  2019-01       100
77  2019-02        80

[78 rows x 2 columns]
Out[ ]:
[48,
 39,
 48,
 48,
 50,
 35,
 33,
 30,
 29,
 27,
 30,
 31,
 40,
 42,
 44,
 66,
 40,
 36,
 29,
 32,
 30,
 31,
 32,
 32,
 40,
 46,
 58,
 55,
 65,
 40,
 39,
 37,
 31,
 33,
 33,
 38,
 39,
 70,
 67,
 82,
 74,
 52,
 43,
 43,
 42,
 36,
 32,
 37,
 49,
 69,
 75,
 86,
 80,
 85,
 58,
 51,
 51,
 45,
 52,
 48,
 63,
 84,
 86,
 81,
 73,
 69,
 61,
 56,
 52,
 50,
 65,
 63,
 74,
 82,
 92,
 97,
 100,
 80]
In [ ]:
plt.plot(point2, label='List 1')
plt.plot(point, label='List 2')

# Adding labels and legend


plt.title('Line Plot of tupras and dogalgaz search Two Lists')
plt.legend()

# Display the plot
plt.show()
No description has been provided for this image
In [ ]:
plt.plot(point2, label='List 1')
plt.plot(point, label='List 2')

# Adding labels and legend

plt.title('Line Plot of tupras and dogalgaz search Two Lists')
plt.legend()

# Display the plot
plt.show()
No description has been provided for this image
In [ ]:
my_list = Data_timeless['AYGAZ']  
AYGAZ= my_list[:-5]
AYGAZ.head(79)
Out[ ]:
0      3.454684
1      3.440262
2      3.692111
3      4.045729
4      4.391287
        ...    
73    11.001865
74    10.356621
75    10.166670
76    10.378431
77    10.157537
Name: AYGAZ, Length: 78, dtype: float64
In [ ]:
plt.plot(point2, label='List 1')
plt.plot(AYGAZ, label='List 2')

# Adding labels and legend

plt.title('Line Plot of tupras and AYGAZ search Two Lists')
plt.legend()

# Display the plot
plt.show()
No description has been provided for this image
In [ ]:
from sklearn.preprocessing import StandardScaler
mean = np.mean(AYGAZ)
std_dev = np.std(AYGAZ)

# Standardize the list
standardized_data2 = [(x - mean) / std_dev for x in AYGAZ]

print("Original Data:", AYGAZ)
print("Standardized Data:", standardized_data2)
Original Data: 0      3.454684
1      3.440262
2      3.692111
3      4.045729
4      4.391287
        ...    
73    11.001865
74    10.356621
75    10.166670
76    10.378431
77    10.157537
Name: AYGAZ, Length: 78, dtype: float64
Standardized Data: [-1.6251116341051677, -1.6305473133480493, -1.535623584792904, -1.4023422536212469, -1.2720990451498697, -1.332059703283792, -1.2047610512374702, -1.150321939725467, -0.5571422305905849, -0.6229099164077705, -0.7963980077632569, -0.8347241445714896, -0.8806390667182825, -0.7370300087385203, -0.8580988475147934, -0.9350539832192772, -0.9634874336628002, -0.9812677346991174, -0.9542463701736354, -0.8745053533788223, -0.8012774412150925, -0.7616474018459362, -0.7674469367738501, -0.6133290120285887, -0.675833091488109, -0.7300554557758279, -0.6084068932053405, -0.5762174702137112, -0.4772977503672464, -0.5451170873931576, -0.6977883993557807, -0.5894714865742811, -0.4850008213238434, -0.4287759495348224, -0.3724819500078027, -0.4082279813549125, -0.5349767838397097, -0.38579747667299197, -0.23662258451434962, -0.413160384459494, -0.5207970057523074, -0.34945032577287655, -0.09836273505150339, 0.17750017981819927, 0.04900006615448127, -0.008993014570297646, 0.07298733924039878, 0.14149914046494944, -0.050039660807416265, 0.01557186975774071, -0.0017603095863625365, 0.10272591014982325, 0.31522912587645857, 0.6767088449969305, 0.940509322900795, 1.2236036088588156, 1.6134835348894905, 1.8309864283676829, 1.7957606573028766, 1.7208387404239558, 1.7173886902585915, 1.6924218475607433, 1.6680184570351526, 1.5812894300265312, 1.8481086817016086, 1.6196559700645397, 1.6466047365286234, 1.7102539606315248, 1.0248928604205079, 0.7033963632591304, 0.5436984814499731, 0.7065704798489846, 1.1618158939019412, 1.2194765791004005, 0.9762794403183661, 0.9046854517391602, 0.9844997511745581, 0.9012431879649893]
In [ ]:
from sklearn.preprocessing import StandardScaler
mean = np.mean(point2)
std_dev = np.std(point2)

# Standardize the list
standardized_data2 = [(x - mean) / std_dev for x in point2]

print("Original Data:", point2)
print("Standardized Data:", standardized_data2)
Original Data: [48, 39, 48, 48, 50, 35, 33, 30, 29, 27, 30, 31, 40, 42, 44, 66, 40, 36, 29, 32, 30, 31, 32, 32, 40, 46, 58, 55, 65, 40, 39, 37, 31, 33, 33, 38, 39, 70, 67, 82, 74, 52, 43, 43, 42, 36, 32, 37, 49, 69, 75, 86, 80, 85, 58, 51, 51, 45, 52, 48, 63, 84, 86, 81, 73, 69, 61, 56, 52, 50, 65, 63, 74, 82, 92, 97, 100, 80]
Standardized Data: [-0.2448277074499042, -0.7131357473132088, -0.2448277074499042, -0.2448277074499042, -0.14075925414694765, -0.9212726539191219, -1.0253411072220786, -1.1814437871765133, -1.2334780138279917, -1.3375464671309483, -1.1814437871765133, -1.1294095605250352, -0.6611015206617306, -0.5570330673587739, -0.45296461405581734, 0.691788372276705, -0.6611015206617306, -0.8692384272676437, -1.2334780138279917, -1.0773753338735568, -1.1814437871765133, -1.1294095605250352, -1.0773753338735568, -1.0773753338735568, -0.6611015206617306, -0.3488961607528608, 0.27551455906487865, 0.1194118791104438, 0.6397541456252267, -0.6611015206617306, -0.7131357473132088, -0.8172042006161654, -1.1294095605250352, -1.0253411072220786, -1.0253411072220786, -0.7651699739646871, -0.7131357473132088, 0.8999252788826181, 0.7438225989281833, 1.5243359987003575, 1.1080621854885313, -0.03669080084399106, -0.5049988407072956, -0.5049988407072956, -0.5570330673587739, -0.8692384272676437, -1.0773753338735568, -0.8172042006161654, -0.19279348079842593, 0.8478910522311398, 1.1600964121400095, 1.7324729053062706, 1.420267545397401, 1.6804386786547925, 0.27551455906487865, -0.08872502749546934, -0.08872502749546934, -0.40093038740433906, -0.03669080084399106, -0.2448277074499042, 0.5356856923222701, 1.628404452003314, 1.7324729053062706, 1.4723017720488794, 1.056027958837053, 0.8478910522311398, 0.43161723901931354, 0.1714461057619221, -0.03669080084399106, -0.14075925414694765, 0.6397541456252267, 0.5356856923222701, 1.1080621854885313, 1.5243359987003575, 2.0446782652151403, 2.304849398472532, 2.460952078426967, 1.420267545397401]
In [ ]:
plt.plot(standardized_data, label='List 1')
plt.plot(standardized_data2, label='List 2')

# Adding labels and legend
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Plot of dogalgaz and AYGAZ search Two Lists')
plt.legend()

# Display the plot
plt.show()
No description has been provided for this image

we can see that after standartizing the dataö the search volume and the seasonalıty also affected the stock prıces about AYGAZ. On the wınter tımes hıgher trend was to search for dogalgazç